Class: Roast::Workflow::ErrorHandler
- Inherits:
-
Object
- Object
- Roast::Workflow::ErrorHandler
- Defined in:
- lib/roast/workflow/error_handler.rb
Overview
Handles error logging and instrumentation for workflow execution
Instance Method Summary collapse
-
#error(message) ⇒ Object
Alias methods for compatibility.
-
#initialize ⇒ ErrorHandler
constructor
A new instance of ErrorHandler.
- #log_error(message) ⇒ Object
- #log_warning(message) ⇒ Object
- #warn(message) ⇒ Object
- #with_error_handling(step_name, resource_type: nil) ⇒ Object
Constructor Details
#initialize ⇒ ErrorHandler
Returns a new instance of ErrorHandler.
7 8 9 |
# File 'lib/roast/workflow/error_handler.rb', line 7 def initialize # Use the Roast logger singleton end |
Instance Method Details
#error(message) ⇒ Object
Alias methods for compatibility
51 52 53 |
# File 'lib/roast/workflow/error_handler.rb', line 51 def error() log_error() end |
#log_error(message) ⇒ Object
42 43 44 |
# File 'lib/roast/workflow/error_handler.rb', line 42 def log_error() Roast::Helpers::Logger.error() end |
#log_warning(message) ⇒ Object
46 47 48 |
# File 'lib/roast/workflow/error_handler.rb', line 46 def log_warning() Roast::Helpers::Logger.warn() end |
#warn(message) ⇒ Object
55 56 57 |
# File 'lib/roast/workflow/error_handler.rb', line 55 def warn() log_warning() end |
#with_error_handling(step_name, resource_type: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/roast/workflow/error_handler.rb', line 11 def with_error_handling(step_name, resource_type: nil) start_time = Time.now ActiveSupport::Notifications.instrument("roast.step.start", { step_name: step_name, resource_type: resource_type, }) result = yield execution_time = Time.now - start_time ActiveSupport::Notifications.instrument("roast.step.complete", { step_name: step_name, resource_type: resource_type, success: true, execution_time: execution_time, result_size: result.to_s.length, }) result rescue WorkflowExecutor::WorkflowExecutorError => e handle_workflow_error(e, step_name, resource_type, start_time) raise rescue CommandExecutor::CommandExecutionError => e handle_workflow_error(e, step_name, resource_type, start_time) raise rescue => e handle_generic_error(e, step_name, resource_type, start_time) end |