Exception: Pocketknife::Error::NodeError::ExecutionError

Inherits:
Pocketknife::Error::NodeError show all
Defined in:
lib/pocketknife/errors.rb

Overview

ExecutionError

Exception raised when something goes wrong executing commands against remote host.

Instance Attribute Summary collapse

Attributes inherited from Pocketknife::Error::NodeError

#node

Instance Method Summary collapse

Constructor Details

#initialize(node, command, cause, immediate) ⇒ ExecutionError

Instantiates a new exception.

Parameters:

  • node (String)

    The name of the unknown node.

  • command (String)

    The command that failed.

  • cause (Rye::Err)

    The actual exception thrown.

  • immediate (Boolean)

    Was execution’s output shown immediately? If so, don’t include output in message.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/pocketknife/errors.rb', line 83

def initialize(node, command, cause, immediate)
  self.command = command
  self.cause = cause
  self.immediate = immediate

  message = <<-HERE.chomp
Failed while executing commands on node '#{node}'
- COMMAND: #{command}
- EXIT STATUS: #{cause.exit_status}
  HERE

  unless immediate
    message << <<-HERE.chomp

- STDOUT: #{cause.stdout.to_s.strip}
- STDERR: #{cause.stderr.to_s.strip}
    HERE
  end

  super(message, node)
end

Instance Attribute Details

#causeRye::Err

Returns Cause of exception, a Rye:Err.

Returns:

  • (Rye::Err)

    Cause of exception, a Rye:Err.



72
73
74
# File 'lib/pocketknife/errors.rb', line 72

def cause
  @cause
end

#commandString

Returns Command that failed.

Returns:

  • (String)

    Command that failed.



69
70
71
# File 'lib/pocketknife/errors.rb', line 69

def command
  @command
end

#immediateBoolean

Returns Was execution’s output shown immediately? If so, don’t include output in message.

Returns:

  • (Boolean)

    Was execution’s output shown immediately? If so, don’t include output in message.



75
76
77
# File 'lib/pocketknife/errors.rb', line 75

def immediate
  @immediate
end

Instance Method Details

#exit_statusInteger

Returns exit status.

Returns:

  • (Integer)

    Exit status from execution.



108
109
110
# File 'lib/pocketknife/errors.rb', line 108

def exit_status
  return self.cause.exit_status
end