class ProcessExecuter::CommandError
Raised when a command fails or exits because of an uncaught signal
The command executed and its result are available from this object.
This 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
result[R]
@attribute [r] result
The result of the command including the command, its status and its output
@example
error.result #=> #<ProcessExecuter::Result:0x00007f9b1b8b3d20>
@return [ProcessExecuter::Result]
Public Class Methods
new(result)
click to toggle source
Create a CommandError
object
@example
`exit 1` # set $? appropriately for this example result_data = { command: ['exit 1'], options: ProcessExecuter::Options::RunOptions.new, timed_out: false, elapsed_time: 0.01 } result = ProcessExecuter::Result.new($?, **result_data) error = ProcessExecuter::CommandError.new(result) error.to_s #=> '["exit 1"], status: pid 29686 exit 1'
@param result [ProcessExecuter::Result] The result of the command including the
command and exit status
Calls superclass method
# File lib/process_executer/errors.rb, line 102 def initialize(result) @result = result super(error_message) end
Public Instance Methods
error_message()
click to toggle source
The human readable representation of this error
@example
error.error_message #=> '["git", "status"], status: pid 89784 exit 1'
@return [String]
# File lib/process_executer/errors.rb, line 114 def error_message "#{result.command}, status: #{result}" end