Exception: GLI::CustomExit
- Inherits:
-
StandardError
- Object
- StandardError
- GLI::CustomExit
- Includes:
- StandardException
- Defined in:
- lib/gli/exceptions.rb
Overview
Raise this if you want to use an exit status that isn’t the default provided by GLI. Note that GLI::App#exit_now! might be a bit more to your liking.
Example:
raise CustomExit.new("Not connected to DB",-5) unless connected?
raise CustomExit.new("Bad SQL",-6) unless valid_sql?(args[0])
Instance Attribute Summary collapse
-
#exit_code ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#initialize(message, exit_code) ⇒ CustomExit
constructor
Create a custom exit exception.
Constructor Details
#initialize(message, exit_code) ⇒ CustomExit
Create a custom exit exception
message-
String containing error message to show the user
exit_code-
the exit code to use (as an Int), overridding GLI’s default
61 62 63 64 |
# File 'lib/gli/exceptions.rb', line 61 def initialize(,exit_code) super() @exit_code = exit_code end |
Instance Attribute Details
#exit_code ⇒ Object (readonly)
:nodoc:
56 57 58 |
# File 'lib/gli/exceptions.rb', line 56 def exit_code @exit_code end |