Class: Timber::Integrations::Rails::ErrorEvent

Inherits:
Timber::Integrations::Rack::Middleware
  • Object
show all
Defined in:
lib/timber-rails/error_event.rb

Overview

A Rack middleware that is reponsible for capturing exception and error events Events::Error.

Constant Summary collapse

EXCEPTION_WRAPPER_TAKES_CLEANER =

We determine this when the app loads to avoid the overhead on a per request basis.

defined?(::ActionDispatch::ExceptionWrapper) &&
!::ActionDispatch::ExceptionWrapper.instance_methods.include?(:env)

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/timber-rails/error_event.rb', line 22

def call(env)
  begin
    status, headers, body = @app.call(env)
  rescue Exception => exception
    Config.instance.logger.fatal do
      backtrace = extract_backtrace(env, exception)
      Events::Error.new(
        name: exception.class.name,
        error_message: exception.message,
        backtrace: backtrace
      )
    end

    raise exception
  end
end