Exception: Cli::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/cli/errors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, exit_code = 1) ⇒ Error

Returns a new instance of Error.



6
7
8
9
# File 'lib/cli/errors.rb', line 6

def initialize(msg, exit_code=1)
  super(msg)
  @exit_code = exit_code
end

Instance Attribute Details

#exit_codeObject (readonly)

Returns the value of attribute exit_code.



5
6
7
# File 'lib/cli/errors.rb', line 5

def exit_code
  @exit_code
end

Class Method Details

.raise(msg, exit_code) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/cli/errors.rb', line 11

def self.raise(msg, exit_code)
  Kernel.raise(if msg.is_a?(self)
                 msg
               else
                 self.new(msg, exit_code)
               end)
end