Class: PostHog::Rails::RescuedExceptionInterceptor Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RescuedExceptionInterceptor.

Parameters:

  • app (#call)

    Rack application.



12
13
14
# File 'lib/posthog/rails/rescued_exception_interceptor.rb', line 12

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Rack response.

Parameters:

  • env (Hash)

    Rack environment.

Returns:

  • (Array)

    Rack response.



18
19
20
21
22
23
24
# File 'lib/posthog/rails/rescued_exception_interceptor.rb', line 18

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