Class: Honeybadger::Rack::ErrorNotifier
- Inherits:
-
Object
- Object
- Honeybadger::Rack::ErrorNotifier
- Extended by:
- Forwardable
- Defined in:
- lib/honeybadger/rack/error_notifier.rb
Overview
Middleware for Rack applications. Any errors raised by the upstream application will be delivered to Honeybadger and re-raised.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, agent = nil) ⇒ ErrorNotifier
constructor
A new instance of ErrorNotifier.
Constructor Details
#initialize(app, agent = nil) ⇒ ErrorNotifier
Returns a new instance of ErrorNotifier.
24 25 26 27 |
# File 'lib/honeybadger/rack/error_notifier.rb', line 24 def initialize(app, agent = nil) @app = app @agent = agent.kind_of?(Agent) && agent 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) agent.with_rack_env(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 agent.clear! end |