class ProcessExecuter::CommandError
Raised when a command fails or exits because of an uncaught signal
The command executed, status, stdout, and stderr are available from this object.
The Gem will raise a more specific error for each type of failure:
-
{FailedError}: when the command exits with a non-zero status
-
{SignaledError}: when the command exits because of an uncaught signal
-
{TimeoutError}: when the command times out
@api public
Attributes
@attribute [r] result
The result of the command including the command, its status and its output
@example
error.result #=> #<ProcessExecuter::Result:0x00007f9b1b8b3d20>
@return [Result]
Public Class Methods
Source
# File lib/process_executer/errors.rb, line 78 def initialize(result) @result = result super(error_message) end
Create a CommandError
object
@example
`exit 1` # set $? appropriately for this example result = ProcessExecuter::Result.new(%w[git status], $?, 'stdout', 'stderr') error = ProcessExecuter::CommandError.new(result) error.to_s #=> '["git", "status"], status: pid 89784 exit 1, stderr: "stderr"'
@param result [Result] The result of the command including the command,
status, stdout, and stderr
Calls superclass method
Public Instance Methods
Source
# File lib/process_executer/errors.rb, line 90 def error_message "#{result.command}, status: #{result}, stderr: #{result.stderr.inspect}" end
The human readable representation of this error
@example
error.error_message #=> '["git", "status"], status: pid 89784 exit 1, stderr: "stderr"'
@return [String]