Class: Alplus::RailsErrorSubscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/alplus/rails_error_subscriber.rb

Overview

Rails 7+ error reporter subscriber (Rails.error.subscribe). Forwards only HANDLED reports (Rails.error.handle/Rails.error.record, or any library that reports through Rails.error) — an UNHANDLED exception already reaches Alplus::RackMiddleware (installed directly around the app, inside ActionDispatch::ShowExceptions) as it propagates up the middleware stack. Subscribing to handled: false here too would double-report the same exception on Rails versions that also route unhandled request exceptions through the error reporter.

Instance Method Summary collapse

Instance Method Details

#report(error, handled:, severity:, context:, source: nil) ⇒ Object



13
14
15
16
17
# File 'lib/alplus/rails_error_subscriber.rb', line 13

def report(error, handled:, severity:, context:, source: nil)
  return unless handled

  Alplus.capture_exception(error, level: severity_to_level(severity), context: context, mechanism: "rails.error_reporter")
end