Class: RailsErrorDashboard::Middleware::ErrorCatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_error_dashboard/middleware/error_catcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ErrorCatcher

Returns a new instance of ErrorCatcher.



18
19
20
# File 'lib/rails_error_dashboard/middleware/error_catcher.rb', line 18

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rails_error_dashboard/middleware/error_catcher.rb', line 22

def call(env)
  @app.call(env)
rescue => exception
  # Report to Rails.error (will be logged by our ErrorReporter)
  Rails.error.report(exception,
    handled: false,
    severity: :error,
    context: {
      request: ActionDispatch::Request.new(env),
      middleware: true
    },
    source: "rack.middleware"
  )

  # Re-raise to let Rails handle the response
  raise exception
end