Exception: ShellHelpers::FailedCommandError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/shell_helpers/sh.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exit_code, command, failure_msg: nil) ⇒ FailedCommandError

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.



139
140
141
142
143
# File 'lib/shell_helpers/sh.rb', line 139

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

Instance Attribute Details

#commandObject (readonly)

The command that caused the failure



133
134
135
# File 'lib/shell_helpers/sh.rb', line 133

def command
  @command
end