Sha256: 165b1e396223bd2b5ed9f2414a83915df464af0035f022b0cce7e1e2f1c443fd

Contents?: true

Size: 689 Bytes

Versions: 8

Compression:

Stored size: 689 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 = {})
      reporter.call(e, context) if reporter
    ensure
      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

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
simpler_workflow-0.3.3 lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.3.2 lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.3.1 lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.3.0 lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.3.0.beta2 lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.3.0.beta lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.2.7 lib/simpler_workflow/default_exception_reporter.rb
simpler_workflow-0.2.6 lib/simpler_workflow/default_exception_reporter.rb