module MotherBrain::Mixin::CodedExit::ClassMethods
Public Instance Methods
exit_code_for(const_name)
click to toggle source
Look up the exit status for motherbrain error matching the given name
@param [String] const_name
name of the error constant to lookup
@example retrieving the exit status for MB::InvalidConfig
exit_code_for("InvalidConfig") #=> 14
@return [Integer]
# File lib/mb/mixin/coded_exit.rb, line 42 def exit_code_for(const_name) MB.const_get(const_name).exit_code end
Also aliased as: exit_status_for
exit_with(obj)
click to toggle source
Exit the application with the exit status associated with the given motherbrain error
@param [String, exit_code] obj
@example exit the application with an exit status for InvalidConfig
(14)
exit_with(MB::InvalidConfig)
@raise [SystemExit]
# File lib/mb/mixin/coded_exit.rb, line 26 def exit_with(obj) err_const = obj.is_a?(String) ? constant_for(obj) : obj exit_code = err_const.try(:exit_code) || MBError::DEFAULT_EXIT_CODE Kernel.exit(exit_code) end