Class: Condux::Rack::CaptureExceptions

Inherits:
Object
  • Object
show all
Defined in:
lib/condux/rack.rb

Overview

Rack middleware: report an uncaught exception (as unhandled) and re-raise, so the app's own error handling still runs. Covers Rails and any Rack app.

# config.ru (Rack)
require "condux/rack"
use Condux::Rack::CaptureExceptions

# Rails (config/application.rb)
config.middleware.use "Condux::Rack::CaptureExceptions"

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ CaptureExceptions

Returns a new instance of CaptureExceptions.



17
18
19
# File 'lib/condux/rack.rb', line 17

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



21
22
23
24
25
26
# File 'lib/condux/rack.rb', line 21

def call(env)
  @app.call(env)
rescue StandardError => e # report anything the app raises, then re-raise
  Condux.capture_exception(e, handled: false)
  raise
end