Class: PostHog::Rails::RescuedExceptionInterceptor

Inherits:
Object
  • Object
show all
Defined in:
lib/posthog/rails/rescued_exception_interceptor.rb

Overview

Middleware that intercepts exceptions that are rescued by Rails This middleware runs before ShowExceptions and captures the exception so we can report it even if Rails rescues it

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RescuedExceptionInterceptor

Returns a new instance of RescuedExceptionInterceptor.



9
10
11
# File 'lib/posthog/rails/rescued_exception_interceptor.rb', line 9

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/posthog/rails/rescued_exception_interceptor.rb', line 13

def call(env)
  @app.call(env)
rescue StandardError => e
  # Store the exception so CaptureExceptions middleware can report it
  env['posthog.rescued_exception'] = e if should_intercept?
  raise e
end