Exception: Methadone::FailedCommandError

Inherits:
Error
  • Object
show all
Defined in:
lib/methadone/error.rb

Overview

Thrown by certain methods when an externally-called command exits nonzero

Instance Attribute Summary (collapse)

Attributes inherited from Error

#exit_code

Instance Method Summary (collapse)

Constructor Details

- (FailedCommandError) initialize(exit_code, command, custom_error_message = nil)

exit_code

exit code of the command that caused this

command

the entire command-line that caused this

custom_error_message

an error message to show the user instead of the boilerplate one. Useful for allowing this exception to bubble up and exit the program, but to give the user something actionable.



26
27
28
29
30
# File 'lib/methadone/error.rb', line 26

def initialize(exit_code,command,custom_error_message = nil)
  error_message = String(custom_error_message).empty? ?  "Command '#{command}' exited #{exit_code}" : custom_error_message
  super(exit_code,error_message)
  @command = command
end

Instance Attribute Details

- (Object) command (readonly)

The command that caused the failure



19
20
21
# File 'lib/methadone/error.rb', line 19

def command
  @command
end