Class: Bugsnag::Middleware::DiscardErrorClass

Inherits:
Object
  • Object
show all
Defined in:
lib/bugsnag/middleware/discard_error_class.rb

Overview

Determines if the exception should be ignored based on the configured `discard_classes`

Instance Method Summary collapse

Constructor Details

#initialize(middleware) ⇒ DiscardErrorClass

Returns a new instance of DiscardErrorClass.

Parameters:

  • middleware (#call)

    The next middleware to call


8
9
10
# File 'lib/bugsnag/middleware/discard_error_class.rb', line 8

def initialize(middleware)
  @middleware = middleware
end

Instance Method Details

#call(report) ⇒ Object

Parameters:


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bugsnag/middleware/discard_error_class.rb', line 14

def call(report)
  should_discard = report.raw_exceptions.any? do |ex|
    report.configuration.discard_classes.any? do |to_ignore|
      case to_ignore
      when String then to_ignore == ex.class.name
      when Regexp then to_ignore =~ ex.class.name
      else false
      end
    end
  end

  report.ignore! if should_discard

  @middleware.call(report)
end