Sha256: 497de0c97befcac005073c8c5724b88e332c82b7042c58542d1ebadfe9bb8df3

Contents?: true

Size: 792 Bytes

Versions: 1

Compression:

Stored size: 792 Bytes

Contents

# frozen_string_literal: true

module Sbmt
  module Strangler
    class ErrorTracker
      class << self
        def error(message, params = {})
          unless defined?(Sentry)
            Sbmt::Strangler.logger.log_error(message, params)
            return
          end

          logging(:error, message, params)
        end

        private

        def logging(level, message, params)
          params = {message: params} if params.is_a?(String)

          Sentry.with_scope do |scope|
            scope.set_contexts(contexts: params)

            if message.is_a?(Exception)
              Sentry.capture_exception(message, level: level)
            else
              Sentry.capture_message(message, level: level)
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sbmt-strangler-0.9.1 lib/sbmt/strangler/error_tracker.rb