Class: SimplerWorkflow::DefaultExceptionReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/simpler_workflow/default_exception_reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#reporterObject

Returns the value of attribute reporter.



6
7
8
# File 'lib/simpler_workflow/default_exception_reporter.rb', line 6

def reporter
  @reporter
end

#tagObject

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
19
20
# File 'lib/simpler_workflow/default_exception_reporter.rb', line 12

def report(e, context = {})
  if reporter
    reporter.call(e, context)
  else
    SimplerWorkflow.logger.error("[#{tag}] Exception: #{e.message}")
    SimplerWorkflow.logger.error("[#{tag}] Context: #{context.inspect}") unless context.empty?
    SimplerWorkflow.logger.error("[#{tag}] Backtrace:\n#{e.backtrace.join("\n")}")
  end
end