Class: Timber::Integrations::Rack::ErrorEvent

Inherits:
Middleware
  • Object
show all
Defined in:
lib/timber/integrations/rack/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.

if Gem.loaded_specs["rails"]
  Gem.loaded_specs["rails"].version >= Gem::Version.new('5.0.0')
else
  false
end

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Timber::Integrations::Rack::Middleware

Instance Method Details

#call(env) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/timber/integrations/rack/error_event.rb', line 27

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