Class: Errsight::CaptureMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/errsight/capture_middleware.rb

Overview

Catches exceptions raised by any inner middleware/controller before ActionDispatch::DebugExceptions converts them into an HTTP response, so

errors that occur outside the controller (e.g. ActiveRecord::Migration

CheckPending, Rack middleware, routing) are still reported with a real backtrace. Inserted after DebugExceptions in the stack so the dev/error page still renders normally on re-raise.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ CaptureMiddleware

Returns a new instance of CaptureMiddleware.



9
10
11
# File 'lib/errsight/capture_middleware.rb', line 9

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/errsight/capture_middleware.rb', line 13

def call(env)
  started = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  @app.call(env)
rescue Exception => exception
  capture(exception, env, started)
  raise
ensure
  Thread.current[:errsight_captured_exceptions] = nil
end