Class: Timber::Integrations::Rack::ExceptionEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/timber/integrations/rack/exception_event.rb

Overview

Reponsible for capturing exceptions events within a Rack stack.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ExceptionEvent

Returns a new instance of ExceptionEvent.



6
7
8
# File 'lib/timber/integrations/rack/exception_event.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/timber/integrations/rack/exception_event.rb', line 10

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

    raise exception
  end
end