Sha256: 210f3ef25a0d591d6f946cd64d170803f9cfa2df19614ea2ab16e9b9b16bec0e

Contents?: true

Size: 1.12 KB

Versions: 10

Compression:

Stored size: 1.12 KB

Contents

module Sentry
  module Rails
    # This is not a user-facing class. You should use it with Rails 7.0's error reporter feature and its interfaces.
    # See https://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`.
    class ErrorSubscriber
      SKIP_SOURCES = Regexp.union([/.*_cache_store.active_support/])

      def report(error, handled:, severity:, context:, source: nil)
        tags = { handled: handled }

        if source
          return if SKIP_SOURCES.match?(source)
          tags[:source] = source
        end

        if context[:tags].is_a?(Hash)
          context = context.dup
          tags.merge!(context.delete(:tags))
        end

        hint = {}
        if context[:hint].is_a?(Hash)
          context = context.dup
          hint.merge!(context.delete(:hint))
        end

        Sentry::Rails.capture_exception(error, level: severity, contexts: { "rails.error" => context }, tags: tags, hint: hint)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sentry-rails-5.20.1 lib/sentry/rails/error_subscriber.rb
sentry-rails-5.20.0 lib/sentry/rails/error_subscriber.rb
sentry-rails-5.19.0 lib/sentry/rails/error_subscriber.rb
sentry-rails-5.18.2 lib/sentry/rails/error_subscriber.rb
sentry-rails-5.18.1 lib/sentry/rails/error_subscriber.rb
sentry-rails-5.18.0 lib/sentry/rails/error_subscriber.rb
sentry-rails-5.17.3 lib/sentry/rails/error_subscriber.rb
sentry-rails-5.17.2 lib/sentry/rails/error_subscriber.rb
sentry-rails-5.17.1 lib/sentry/rails/error_subscriber.rb
sentry-rails-5.17.0 lib/sentry/rails/error_subscriber.rb