Method: Arcanus::ErrorHandler#handle

Defined in:
lib/arcanus/error_handler.rb

#handle(ex) ⇒ Integer

Display appropriate output to the user for the given exception, returning a semantic exit status code.

Returns:

  • (Integer)

    exit status code



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/arcanus/error_handler.rb', line 16

def handle(ex)
  case ex
  when Errors::CommandFailedError,
       Errors::DecryptionError
    ui.error ex.message
    CLI::ExitCodes::ERROR
  when Errors::UsageError
    ui.error ex.message
    CLI::ExitCodes::USAGE
  when Errors::ConfigurationError
    ui.error ex.message
    CLI::ExitCodes::CONFIG
  else
    print_unexpected_exception(ex)
    CLI::ExitCodes::SOFTWARE
  end
end