Sha256: d404cf594ec4b966d828eb4d9f16d5e6413f82a33be26dea1c2ad6c9b7a5826e

Contents?: true

Size: 778 Bytes

Versions: 9

Compression:

Stored size: 778 Bytes

Contents

require 'pact_broker/configuration'
require 'pact_broker/logging'

module PactBroker
  module Errors
    class ErrorLogger
      include PactBroker::Logging

      # don't need the env, just in case PF needs it
      def self.call(error, error_reference, env = {})
        if log_as_warning?(error)
          logger.warn("Error reference #{error_reference}", error)
        elsif PactBroker::Errors.reportable_error?(error)
          log_error(error, "Error reference #{error_reference}")
        else
          logger.info("Error reference #{error_reference}", error)
        end
      end

      def self.log_as_warning?(error)
        PactBroker.configuration.warning_error_classes.any? { |clazz| error.is_a?(clazz) || error.cause&.is_a?(clazz) }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pact_broker-2.79.1 lib/pact_broker/errors/error_logger.rb
pact_broker-2.79.0 lib/pact_broker/errors/error_logger.rb
pact_broker-2.78.1 lib/pact_broker/errors/error_logger.rb
pact_broker-2.78.0 lib/pact_broker/errors/error_logger.rb
pact_broker-2.77.0 lib/pact_broker/errors/error_logger.rb
pact_broker-2.76.2 lib/pact_broker/errors/error_logger.rb
pact_broker-2.76.1 lib/pact_broker/errors/error_logger.rb
pact_broker-2.76.0 lib/pact_broker/errors/error_logger.rb
pact_broker-2.75.0 lib/pact_broker/errors/error_logger.rb