Class: Honeybadger::Rack::ErrorNotifier
- Inherits:
-
Object
- Object
- Honeybadger::Rack::ErrorNotifier
- Extended by:
- Forwardable
- Defined in:
- lib/honeybadger/rack/error_notifier.rb
Overview
Public: Middleware for Rack applications. Any errors raised by the upstream application will be delivered to Honeybadger and re-raised.
Examples:
require 'honeybadger/rack/error_notifier'
app = Rack::Builder.app do
run lambda { |env| raise "Rack down" }
end
use Honeybadger::Rack::ErrorNotifier
run app
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, config) ⇒ ErrorNotifier
constructor
A new instance of ErrorNotifier.
Constructor Details
#initialize(app, config) ⇒ ErrorNotifier
Returns a new instance of ErrorNotifier.
24 25 26 27 |
# File 'lib/honeybadger/rack/error_notifier.rb', line 24 def initialize(app, config) @app = app @config = config end |
Instance Method Details
#call(env) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/honeybadger/rack/error_notifier.rb', line 29 def call(env) config.with_request(::Rack::Request.new(env)) do begin env['honeybadger.config'] = config response = @app.call(env) rescue Exception => raised env['honeybadger.error_id'] = notify_honeybadger(raised, env) raise end framework_exception = framework_exception(env) if framework_exception env['honeybadger.error_id'] = notify_honeybadger(framework_exception, env) end response end ensure Honeybadger.context.clear! end |