Class: Dbwatcher::Services::DiagramErrorHandler
- Inherits:
-
Object
- Object
- Dbwatcher::Services::DiagramErrorHandler
- Defined in:
- lib/dbwatcher/services/diagram_error_handler.rb
Overview
Centralized error handling for diagram generation
Provides consistent error categorization, logging, and response formatting for all diagram generation failures with recovery strategies.
Defined Under Namespace
Classes: DiagramGenerationError
Constant Summary collapse
- ERROR_CODES =
Error code mapping for consistent error identification
{ session_not_found: "DIAGRAM_001", invalid_diagram_type: "DIAGRAM_002", syntax_validation_failed: "DIAGRAM_003", generation_timeout: "DIAGRAM_004", insufficient_data: "DIAGRAM_005", analyzer_error: "DIAGRAM_006", cache_error: "DIAGRAM_007", system_error: "DIAGRAM_099" }.freeze
Instance Method Summary collapse
-
#handle_generation_error(error, context = {}) ⇒ Hash
Handle diagram generation error with categorization and logging.
-
#initialize(config = {}) ⇒ DiagramErrorHandler
constructor
Initialize error handler with configuration.
-
#recoverable_error?(error_code) ⇒ Boolean
Check if an error type is recoverable.
Constructor Details
#initialize(config = {}) ⇒ DiagramErrorHandler
Initialize error handler with configuration
45 46 47 48 |
# File 'lib/dbwatcher/services/diagram_error_handler.rb', line 45 def initialize(config = {}) @config = default_config.merge(config) @logger = @config[:logger] || default_logger end |
Instance Method Details
#handle_generation_error(error, context = {}) ⇒ Hash
Handle diagram generation error with categorization and logging
55 56 57 58 59 60 61 |
# File 'lib/dbwatcher/services/diagram_error_handler.rb', line 55 def handle_generation_error(error, context = {}) error_info = categorize_error(error, context) log_error(error_info) # Return user-friendly error response create_error_response(error_info) end |
#recoverable_error?(error_code) ⇒ Boolean
Check if an error type is recoverable
67 68 69 70 71 72 73 74 75 |
# File 'lib/dbwatcher/services/diagram_error_handler.rb', line 67 def recoverable_error?(error_code) recoverable_codes = [ ERROR_CODES[:syntax_validation_failed], ERROR_CODES[:generation_timeout], ERROR_CODES[:insufficient_data], ERROR_CODES[:cache_error] ] recoverable_codes.include?(error_code) end |