Sha256: 0dcb97c32c94ea6b1582ed1009bbb9db4e85874243a4370a670295e8bd8f1b63

Contents?: true

Size: 945 Bytes

Versions: 25

Compression:

Stored size: 945 Bytes

Contents

module HoptoadNotifier
  # Middleware for Rack applications. Any errors raised by the upstream
  # application will be delivered to Hoptoad and re-raised.
  #
  # Synopsis:
  #
  #   require 'rack'
  #   require 'hoptoad_notifier'
  #
  #   HoptoadNotifier.configure do |config|
  #     config.api_key = 'my_api_key'
  #   end
  #
  #   app = Rack::Builder.app do
  #     use HoptoadNotifier::Rack
  #     run lambda { |env| raise "Rack down" }
  #   end
  #
  # Use a standard HoptoadNotifier.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
        HoptoadNotifier.notify_or_ignore(raised, :rack_env => env)
        raise
      end

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

      response
    end
  end
end

Version data entries

25 entries across 25 versions & 5 rubygems

Version Path
hoptoad_notifier-2.4.2 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.4.1 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.4.0 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.3.12 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.3.11 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.3.10 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.3.9 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.3.8 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.3.7 lib/hoptoad_notifier/rack.rb
riscfuture-hoptoad_notifier-2.3.6 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.3.6 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.3.5 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.3.4 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.3.3 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.3.2 lib/hoptoad_notifier/rack.rb
jordan-brough-hoptoad_notifier-2.3.0 lib/hoptoad_notifier/rack.rb
hoptoad_notifier-2.3.0 lib/hoptoad_notifier/rack.rb
hatless-hoptoad_notifier-2.2.6.1 lib/hoptoad_notifier/rack.rb
hatless-hoptoad_notifier-2.2.6.001 lib/hoptoad_notifier/rack.rb
hatless-hoptoad_notifier-2.2.6 lib/hoptoad_notifier/rack.rb