Class: Dispatch::Rails::ErrorSubscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/dispatch/rails/error_subscriber.rb

Overview

Subscribes to Rails.error (ActiveSupport::ErrorReporter). Catches errors outside the web request — ActiveJob failures, runners, and explicit Rails.error.handle/record blocks. Request errors already captured by the Rack middleware carry a marker and are skipped here, so nothing is double-counted.

Constant Summary collapse

SEVERITY_TO_LEVEL =
{ error: "error", warning: "warning", info: "info" }.freeze

Instance Method Summary collapse

Instance Method Details

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



11
12
13
14
15
16
17
18
19
20
# File 'lib/dispatch/rails/error_subscriber.rb', line 11

def report(error, handled:, severity: :error, context: {}, source: nil)
  return if source.to_s.start_with?("dispatch")

  Dispatch::Rails::Reporter.capture(
    error,
    handled: handled,
    context: { tags: context_tags(context, source) },
    level: SEVERITY_TO_LEVEL.fetch(severity, "error")
  )
end