Module: RailsLens::CLIErrorHandler

Included in:
CLI
Defined in:
lib/rails_lens/cli_error_handler.rb

Overview

Provides consistent error handling for CLI commands

Instance Method Summary collapse

Instance Method Details

#with_error_handlingObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rails_lens/cli_error_handler.rb', line 6

def with_error_handling
  yield
rescue Interrupt
  say "\nOperation cancelled by user", :yellow
  exit 1
rescue ConfigurationError => e
  handle_configuration_error(e)
rescue ModelDetectionError => e
  handle_model_error(e)
rescue DatabaseError => e
  handle_database_error(e)
rescue AnnotationError => e
  handle_annotation_error(e)
rescue ExtensionError => e
  handle_extension_error(e)
rescue StandardError => e
  handle_unexpected_error(e)
end