Sha256: 6822d3e50685870f3862075464ad8303b34b4d139115a7c110460c10d750c21b

Contents?: true

Size: 713 Bytes

Versions: 8

Compression:

Stored size: 713 Bytes

Contents

# Default exception handler. Just logs to the logger and re-raise
# so the exception can be managed as usual.

module SimplerWorkflow
  class DefaultExceptionReporter
    attr_accessor :reporter, :tag

    def initialize(&block)
      @reporter = block if block_given?
    end

    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

    def tag
      @tag || "SimplerWorkflow"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
simpler_workflow-0.2.5 lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.1.12 lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.2.4 lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.1.11 lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.2.3 lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.1.10 lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.2.1 lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.1.9 lib/simpler_workflow/default_exception_reporter.rb