Class: Bugsnag::Middleware::ClassifyError

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

Overview

Sets the severity to info for low-importance errors

Constant Summary collapse

INFO_CLASSES =
[
    "AbstractController::ActionNotFound",
    "ActionController::InvalidAuthenticityToken",
    "ActionController::ParameterMissing",
    "ActionController::UnknownAction",
    "ActionController::UnknownFormat",
    "ActionController::UnknownHttpMethod",
    "ActionDispatch::Http::MimeNegotiation::InvalidType",
    "ActiveRecord::RecordNotFound",
    "CGI::Session::CookieStore::TamperedWithCookie",
    "Mongoid::Errors::DocumentNotFound",
    "SignalException",
    "SystemExit"
]

Instance Method Summary collapse

Constructor Details

#initialize(bugsnag) ⇒ ClassifyError

Returns a new instance of ClassifyError.



20
21
22
# File 'lib/bugsnag/middleware/classify_error.rb', line 20

def initialize(bugsnag)
  @bugsnag = bugsnag
end

Instance Method Details

#call(report) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bugsnag/middleware/classify_error.rb', line 24

def call(report)
  report.raw_exceptions.each do |ex|

    ancestor_chain = ex.class.ancestors.select {
      |ancestor| ancestor.is_a?(Class)
    }.map {
      |ancestor| ancestor.to_s
    }

    INFO_CLASSES.each do |info_class|
      if ancestor_chain.include?(info_class)
        report.severity_reason = {
          :type => Bugsnag::Report::ERROR_CLASS,
          :attributes => {
            :errorClass => info_class
          }
        }
        report.severity = 'info'
        break
      end
    end
  end

  @bugsnag.call(report)
end