bugsnag/bugsnag-ruby

skip_bugsnag is not functioning

jibiking opened this issue · 1 comments

Describe the bug

The description in the official documentation states that even when using the "skip_bugsnag" configuration, notifications to Bugsnag are not stopping.
Has the bug in this issue not been resolved?
#470

Steps to reproduce

sample code↓

    begin
      raise StandardError
    rescue StandardError => exception

      Bugsnag.notify(exception)
      exception.instance_eval { def skip_bugsnag; true; end }

      raise ActionController::RoutingError, 'not_found'
    end

Environment

  • ruby3.1.4
  • raills6.1
  • gem bugsnag6.26.0

Hey, @jibiking

skip_bugsnag works on the specific instance of the exception you apply it to. In your example you're applying it to exception but raising a RoutingError afterwards. That means that the RoutingError doesn't have skip_bugsnag applied to it, which results in it being reported to Bugsnag

To make it work you'd need to apply skip_bugsnag to the RoutingError before raising it, like this:

begin
  raise StandardError
rescue StandardError => exception
  Bugsnag.notify(exception)

  routing_error = ActionController::RoutingError.new('not_found')
  routing_error.instance_eval { def skip_bugsnag; true; end }

  raise routing_error
end

If you want to ignore all RoutingError exceptions, take a look at the discard_classes configuration option

Hope that helps!