Sha256: 81d63f91d9358b031ed54e30d4fd4c8d04c00ccf51d11f2f5b314bd921fa6af2

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

module Bugsnag::Middleware
  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(notification)
      notification.exceptions.each do |ex|

        outer_break = false

        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)
            notification.severity_reason = {
              :type => Bugsnag::Notification::ERROR_CLASS,
              :attributes => {
                :errorClass => info_class
              }
            }
            notification.severity = 'info'
            outer_break = true
            break
          end
        end

        break if outer_break
      end

      @bugsnag.call(notification)
    end
  end
end
    

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bugsnag-5.5.0 lib/bugsnag/middleware/classify_error.rb
bugsnag-5.4.1 lib/bugsnag/middleware/classify_error.rb
bugsnag-5.4.0 lib/bugsnag/middleware/classify_error.rb