class Sfn::Error
Constants
- DEFAULT_EXIT_CODE
Exit code used when no custom code provided
Attributes
exit_code[R]
@return [Integer] exit code to report
original[R]
@return [Exception, nil] original exception
Public Class Methods
error_msg(m = nil)
click to toggle source
# File lib/sfn/error.rb, line 18 def self.error_msg(m = nil) if m || !defined?(@error_msg) @error_msg = m end @error_msg end
exit_code(c = nil)
click to toggle source
# File lib/sfn/error.rb, line 11 def self.exit_code(c = nil) if c || !defined?(@exit_code) @exit_code = c.to_i != 0 ? c : DEFAULT_EXIT_CODE end @exit_code end
new(*args)
click to toggle source
Calls superclass method
# File lib/sfn/error.rb, line 25 def initialize(*args) opts = args.detect { |a| a.is_a?(Hash) } || {} opts = opts.to_smash msg = args.first.is_a?(String) ? args.first : self.class.error_msg super(msg) @exit_code = opts.fetch(:exit_code, self.class.exit_code).to_i if opts[:original] if opts[:original].is_a?(Exception) @original = opts[:original] else raise TypeError.new "Expected `Exception` type in `:original` " \ "option but received `#{opts[:original].class}`" end end end