Parent

Airbrake::Rack

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

Synopsis:

require 'rack'
require 'airbrake'

Airbrake.configure do |config|
  config.api_key = 'my_api_key'
end

app = Rack::Builder.app do
  run lambda { |env| raise "Rack down" }
end

use Airbrake::Rack
run app

Use a standard Airbrake.configure call to configure your api key.

Public Class Methods

new(app) click to toggle source
# File lib/airbrake/rack.rb, line 23
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/airbrake/rack.rb, line 39
def call(env)
  begin
    response = @app.call(env)
  rescue Exception => raised
    env['airbrake.error_id'] = notify_airbrake(raised,env)
    raise
  end

  if env['rack.exception']
    env['airbrake.error_id'] = notify_airbrake(env['rack.exception'],env)
  end

  response
end
ignored_user_agent?(env) click to toggle source
# File lib/airbrake/rack.rb, line 27
def ignored_user_agent?(env)
  true if Airbrake.
    configuration.
    ignore_user_agent.
    flatten.
    any? { |ua| ua === env['HTTP_USER_AGENT'] }
end
notify_airbrake(exception,env) click to toggle source
# File lib/airbrake/rack.rb, line 35
def notify_airbrake(exception,env)
  Airbrake.notify_or_ignore(exception,:rack_env => env) unless ignored_user_agent?(env)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.