class Saddle::Middleware::Logging::AirbrakeLogger

Public: Reports exceptions to Airbrake

Public Class Methods

new(app, airbrake_api_key=nil) click to toggle source
Calls superclass method
# File lib/saddle/middleware/logging/airbrake.rb, line 14
def initialize(app, airbrake_api_key=nil)
  super(app)
  @airbrake_api_key = airbrake_api_key
end

Public Instance Methods

call(env) click to toggle source
# File lib/saddle/middleware/logging/airbrake.rb, line 19
def call(env)
  begin
    @app.call(env)
  rescue => e
    # If we don't have an api key, use the default config
    begin
      if @airbrake_api_key
        ::Airbrake.notify(e, {:api_key => @airbrake_api_key} )
      else
        ::Airbrake.notify(e)
      end
    rescue
      # Never ever fail because we couldn't talk to Airbrake
    end
    # Re-raise the error
    raise
  end
end