Method: Climate.handle_error

Defined in:
lib/climate.rb

.handle_error(e, options) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/climate.rb', line 32

def self.handle_error(e, options)
  case e
  when ExitException
    # exit silently if there is no error message to print out
    stderr.puts(e.message) if e.has_message?
    e.exit_code
  when HelpNeeded
    help(e.command_class).print(options)
    0
  when ParsingError
    stderr.puts(error_messages[e.class].call(e))
    help(e.command_class).print_usage
    1
  else
    stderr.puts("Unexpected error: #{e.class.name} - #{e.message}")
    stderr.puts(e.backtrace)
    2
  end
end