Exception: Rodish::CommandFailure
- Inherits:
-
CommandExit
- Object
- StandardError
- CommandExit
- Rodish::CommandFailure
- Defined in:
- lib/rodish/errors.rb
Overview
Rodish::CommandFailure is used for failures of commands, such as:
-
Invalid options
-
Invalid number of arguments for a command
-
Invalid subcommands
-
No subcommand given for a command that only supports subcommands
Direct Known Subclasses
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Instance Method Summary collapse
-
#failure? ⇒ Boolean
Always returns false, since CommandFailure represents failures.
-
#initialize(message, command = nil) ⇒ CommandFailure
constructor
A new instance of CommandFailure.
-
#message_with_usage ⇒ Object
Return the message along with the content of any related option parsers.
Constructor Details
#initialize(message, command = nil) ⇒ CommandFailure
Returns a new instance of CommandFailure.
31 32 33 34 |
# File 'lib/rodish/errors.rb', line 31 def initialize(, command=nil) @command = command super() end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
29 30 31 |
# File 'lib/rodish/errors.rb', line 29 def command @command end |
Instance Method Details
#failure? ⇒ Boolean
Always returns false, since CommandFailure represents failures.
37 38 39 |
# File 'lib/rodish/errors.rb', line 37 def failure? true end |
#message_with_usage ⇒ Object
Return the message along with the content of any related option parsers. This can be used to show usage an options along with error messages for failing commands.
44 45 46 47 48 49 50 51 |
# File 'lib/rodish/errors.rb', line 44 def help = @command&.help || '' if help.empty? else "#{message}\n\n#{help}" end end |