Class: Gerrit::ErrorHandler
- Inherits:
-
Object
- Object
- Gerrit::ErrorHandler
- Defined in:
- lib/gerrit/error_handler.rb
Overview
Central location of all logic for how exceptions are presented to the user.
Instance Method Summary collapse
-
#handle(ex) ⇒ Integer
Display appropriate output to the user for the given exception, returning a semantic exit status code.
-
#initialize(ui) ⇒ ErrorHandler
constructor
Creates exception handler that can display output to user via the given user interface.
Constructor Details
#initialize(ui) ⇒ ErrorHandler
Creates exception handler that can display output to user via the given user interface.
8 9 10 |
# File 'lib/gerrit/error_handler.rb', line 8 def initialize(ui) @ui = ui end |
Instance Method Details
#handle(ex) ⇒ Integer
Display appropriate output to the user for the given exception, returning a semantic exit status code.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gerrit/error_handler.rb', line 16 def handle(ex) case ex when Errors::UsageError ui.error ex. CLI::ExitCodes::USAGE when Errors::ConfigurationError ui.error ex. CLI::ExitCodes::CONFIG when Errors::GerritCommandFailedError ui.error ex. CLI::ExitCodes::ERROR else print_unexpected_exception(ex) CLI::ExitCodes::SOFTWARE end end |