Class: Sentry::Rails::ErrorSubscriber
- Inherits:
-
Object
- Object
- Sentry::Rails::ErrorSubscriber
- Defined in:
- lib/sentry/rails/error_subscriber.rb
Overview
This is not a user-facing class. You should use it with Rails 7.0’s error reporter feature and its interfaces. See github.com/rails/rails/blob/main/activesupport/lib/active_support/error_reporter.rb to learn more about reporting APIs. If you want Sentry to subscribe to the error reporter, please set ‘config.rails.register_error_subscriber` to `true`.
Constant Summary collapse
- SKIP_SOURCES =
Regexp.union([/.*_cache_store.active_support/])
Instance Method Summary collapse
Instance Method Details
#log_debug(message) ⇒ Object
42 43 44 |
# File 'lib/sentry/rails/error_subscriber.rb', line 42 def log_debug() Sentry.configuration.logger.debug() end |
#report(error, handled:, severity:, context:, source: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sentry/rails/error_subscriber.rb', line 11 def report(error, handled:, severity:, context:, source: nil) = { handled: handled } if source return if SKIP_SOURCES.match?(source) [:source] = source end if context[:tags].is_a?(Hash) context = context.dup .merge!(context.delete(:tags)) end hint = {} if context[:hint].is_a?(Hash) context = context.dup hint.merge!(context.delete(:hint)) end = { level: severity, contexts: { "rails.error" => context }, tags: , hint: hint } case error when String Sentry::Rails.(error, **) when Exception Sentry::Rails.capture_exception(error, **) else log_debug("Expected an Exception or a String, got: #{error.inspect}") end end |