Sha256: 335f966009c9fa4499c63e0471cef7bb1809daec1dbebaa1c96df9dbb5d6deb2

Contents?: true

Size: 697 Bytes

Versions: 5

Compression:

Stored size: 697 Bytes

Contents

require 'airbrake'
require 'faraday'



module Saddle::Middleware
  module Logging

    # Public: Reports exceptions to Airbrake
    #
    class AirbrakeLogger < Faraday::Middleware

      def initialize(app, airbrake_api_key=nil)
        super(app)
        @airbrake_api_key = airbrake_api_key
      end

      def call(env)
        begin
          @app.call(env)
        rescue => e
          # If we don't have an api key, use the default config
          if @airbrake_api_key
            ::Airbrake.notify(e, {:api_key => @airbrake_api_key} )
          else
            ::Airbrake.notify(e)
          end
          # Re-raise the error
          raise
        end
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
saddle-0.0.12 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.11 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.10 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.7 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.6 lib/saddle/middleware/logging/airbrake.rb