Class: CloseYourIt::Rails::ErrorSubscriber
- Inherits:
-
Object
- Object
- CloseYourIt::Rails::ErrorSubscriber
- Defined in:
- lib/closeyourit/rails/error_subscriber.rb
Overview
Sottoscrittore di ‘ActiveSupport::ErrorReporter` (Rails 7+): cattura gli errori HANDLED riportati via `Rails.error.report`/`Rails.error.handle`. Gli unhandled passano già dal middleware Rack → la dedup (ivar sull’istanza) evita il doppio invio.
Constant Summary collapse
- SEVERITY_TO_LEVEL =
{ error: "error", warning: "warning", info: "info" }.freeze
- IGNORED_SOURCES =
Sorgenti interne rumorose da non inoltrare (evita loop/duplicati).
%w[closeyourit].freeze
Instance Method Summary collapse
Instance Method Details
#report(error, handled:, severity:, context:, source: nil) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/closeyourit/rails/error_subscriber.rb', line 14 def report(error, handled:, severity:, context:, source: nil) return if source && IGNORED_SOURCES.include?(source) return unless CloseYourIt.configuration.capture_handled_errors level = SEVERITY_TO_LEVEL.fetch(severity, "error") contexts = context && !context.empty? ? { "rails_error" => stringify(context) } : nil CloseYourIt.capture_exception(error, handled: handled, level: level, contexts: contexts) end |