Class: SimplerWorkflow::DefaultExceptionReporter
- Inherits:
-
Object
- Object
- SimplerWorkflow::DefaultExceptionReporter
- Defined in:
- lib/simpler_workflow/default_exception_reporter.rb
Instance Attribute Summary collapse
-
#reporter ⇒ Object
Returns the value of attribute reporter.
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
-
#initialize(&block) ⇒ DefaultExceptionReporter
constructor
A new instance of DefaultExceptionReporter.
- #report(e, context = {}) ⇒ Object
Constructor Details
#initialize(&block) ⇒ DefaultExceptionReporter
Returns a new instance of DefaultExceptionReporter.
8 9 10 |
# File 'lib/simpler_workflow/default_exception_reporter.rb', line 8 def initialize(&block) @reporter = block if block_given? end |
Instance Attribute Details
#reporter ⇒ Object
Returns the value of attribute reporter.
6 7 8 |
# File 'lib/simpler_workflow/default_exception_reporter.rb', line 6 def reporter @reporter end |
#tag ⇒ Object
Returns the value of attribute tag.
6 7 8 |
# File 'lib/simpler_workflow/default_exception_reporter.rb', line 6 def tag @tag end |
Instance Method Details
#report(e, context = {}) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/simpler_workflow/default_exception_reporter.rb', line 12 def report(e, context = {}) reporter.call(e, context) if reporter ensure SimplerWorkflow.logger.error("[#{tag}] Exception: #{e.}") SimplerWorkflow.logger.error("[#{tag}] Context: #{context.inspect}") unless context.empty? SimplerWorkflow.logger.error("[#{tag}] Backtrace:\n#{e.backtrace.join("\n")}") end |