Sha256: 32a1abe5cb215d5d41637b2b2e7744004b63940ba56cd72b3548930c88b2fc63

Contents?: true

Size: 953 Bytes

Versions: 5

Compression:

Stored size: 953 Bytes

Contents

module ErrornotNotifier
  # Middleware for Rack applications. Any errors raised by the upstream
  # application will be delivered to Errornot and re-raised.
  #
  # Synopsis:
  #
  #   require 'rack'
  #   require 'errornot_notifier'
  #
  #   ErrornotNotifier.configure do |config|
  #     config.api_key = 'my_api_key'
  #   end
  #
  #   app = Rack::Builder.app do
  #     use ErrornotNotifier::Rack
  #     run lambda { |env| raise "Rack down" }
  #   end
  #
  # Use a standard ErrornotNotifier.configure call to configure your api key.
  class Rack
    def initialize(app)
      @app = app
    end

    def call(env)
      begin
        response = @app.call(env)
      rescue Exception => raised
        ErrornotNotifier.notify_or_ignore(raised, :rack_env => env)
        raise
      end

      if env['rack.exception']
        ErrornotNotifier.notify_or_ignore(env['rack.exception'], :rack_env => env)
      end

      response
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
errornot_notifier-1.1.1 lib/errornot_notifier/rack.rb
errornot_notifier-1.1.0 lib/errornot_notifier/rack.rb
errornot_notifier-1.0.2 lib/errornot_notifier/rack.rb
errornot_notifier-1.0.1 lib/errornot_notifier/rack.rb
errornot_notifier-1.0.0 lib/errornot_notifier/rack.rb