Sha256: e20b2c929ab4a67c591c888d8f120483f7b479b72cb4ec8b7f94a82f97b387e6

Contents?: true

Size: 1.28 KB

Versions: 21

Compression:

Stored size: 1.28 KB

Contents

module Bugsnag::Middleware
  ##
  # Sets the severity to info for low-importance errors
  class ClassifyError
    INFO_CLASSES = [
        "AbstractController::ActionNotFound",
        "ActionController::InvalidAuthenticityToken",
        "ActionController::ParameterMissing",
        "ActionController::UnknownAction",
        "ActionController::UnknownFormat",
        "ActionController::UnknownHttpMethod",
        "ActiveRecord::RecordNotFound",
        "CGI::Session::CookieStore::TamperedWithCookie",
        "Mongoid::Errors::DocumentNotFound",
        "SignalException",
        "SystemExit"
    ]

    def initialize(bugsnag)
      @bugsnag = bugsnag
    end

    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
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
bugsnag-6.19.0 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.18.0 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.17.0 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.16.0 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.15.0 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.14.0 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.13.1 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.13.0 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.12.2 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.12.1 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.12.0 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.11.1 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.11.0 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.10.0 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.9.0 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.8.0 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.7.3 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.7.2 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.7.1 lib/bugsnag/middleware/classify_error.rb
bugsnag-6.7.0 lib/bugsnag/middleware/classify_error.rb