Sha256: fb234e5b5572c9d94dededca5294e87c3d9a2433c0d8d8f6909bc79188543914

Contents?: true

Size: 881 Bytes

Versions: 25

Compression:

Stored size: 881 Bytes

Contents

# frozen_string_literal: true
require 'sidekiq'

module Sidekiq
  module ExceptionHandler

    class Logger
      def call(ex, ctxHash)
        Sidekiq.logger.warn(Sidekiq.dump_json(ctxHash)) if !ctxHash.empty?
        Sidekiq.logger.warn "#{ex.class.name}: #{ex.message}"
        Sidekiq.logger.warn ex.backtrace.join("\n") unless ex.backtrace.nil?
      end

      # Set up default handler which just logs the error
      Sidekiq.error_handlers << Sidekiq::ExceptionHandler::Logger.new
    end

    def handle_exception(ex, ctxHash={})
      Sidekiq.error_handlers.each do |handler|
        begin
          handler.call(ex, ctxHash)
        rescue => ex
          Sidekiq.logger.error "!!! ERROR HANDLER THREW AN ERROR !!!"
          Sidekiq.logger.error ex
          Sidekiq.logger.error ex.backtrace.join("\n") unless ex.backtrace.nil?
        end
      end
    end

  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
sidekiq-5.0.5 lib/sidekiq/exception_handler.rb
sidekiq-5.0.4 lib/sidekiq/exception_handler.rb
sidekiq-5.0.3 lib/sidekiq/exception_handler.rb
sidekiq-5.0.2 lib/sidekiq/exception_handler.rb
sidekiq-5.0.1 lib/sidekiq/exception_handler.rb
sidekiq-5.0.0 lib/sidekiq/exception_handler.rb
sidekiq-5.0.0.rc1 lib/sidekiq/exception_handler.rb
sidekiq-5.0.0.beta3 lib/sidekiq/exception_handler.rb
sidekiq-4.2.10 lib/sidekiq/exception_handler.rb
sidekiq-5.0.0.beta2 lib/sidekiq/exception_handler.rb
sidekiq-5.0.0.beta1 lib/sidekiq/exception_handler.rb
sidekiq-4.2.9 lib/sidekiq/exception_handler.rb
sidekiq-4.2.8 lib/sidekiq/exception_handler.rb
sidekiq-4.2.7 lib/sidekiq/exception_handler.rb
sidekiq-4.2.6 lib/sidekiq/exception_handler.rb
sidekiq-4.2.5 lib/sidekiq/exception_handler.rb
sidekiq-4.2.4 lib/sidekiq/exception_handler.rb
sidekiq-4.2.3 lib/sidekiq/exception_handler.rb
sidekiq-4.2.2 lib/sidekiq/exception_handler.rb
sidekiq-4.2.1 lib/sidekiq/exception_handler.rb