Exception: Cuken::Api::Chef::Knife::CommandFailed

Inherits:
StandardError
  • Object
show all
Defined in:
lib/cuken/api/chef/knife.rb

Overview

Raised when a command exits with non-zero.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, exitstatus = nil, err = '') ⇒ CommandFailed

Returns a new instance of CommandFailed.



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/cuken/api/chef/knife.rb', line 53

def initialize(command, exitstatus=nil, err='')
  if exitstatus
    @command = command
    @exitstatus = exitstatus
    @err = err
    message = "Command failed [#{exitstatus}]: #{command}"
    message << "\n\n" << err unless err.nil? || err.empty?
    super message
  else
    super command
  end
end

Instance Attribute Details

#commandObject (readonly)

The full command that failed as a String.



45
46
47
# File 'lib/cuken/api/chef/knife.rb', line 45

def command
  @command
end

#errObject (readonly)

Everything output on the command’s stderr as a String.



51
52
53
# File 'lib/cuken/api/chef/knife.rb', line 51

def err
  @err
end

#exitstatusObject (readonly)

The integer exit status.



48
49
50
# File 'lib/cuken/api/chef/knife.rb', line 48

def exitstatus
  @exitstatus
end