Class: Airbrake::Rails::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/airbrake/rails/middleware.rb

Overview

Rack middleware for Rails applications. Any errors raised by the upstream application will be delivered to Airbrake and re-raised.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



7
8
9
# File 'lib/airbrake/rails/middleware.rb', line 7

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/airbrake/rails/middleware.rb', line 11

def call(env)
  begin
    response = @app.call(env)
  rescue Exception => exception
    env['airbrake.error_id'] = notify_airbrake(env, exception)
    raise exception
  end

  if framework_exception = env["action_dispatch.exception"]
    env["airbrake.error_id"] = notify_airbrake(env, framework_exception)
  end

  response
end