1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/lib/sidekiq/exception_handler.rb

28 lines
774 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require "sidekiq"
2014-02-24 23:47:44 -05:00
module Sidekiq
module ExceptionHandler
2014-02-24 23:47:44 -05:00
class Logger
def call(ex, ctx)
Sidekiq.logger.warn(Sidekiq.dump_json(ctx)) unless ctx.empty?
Sidekiq.logger.warn("#{ex.class.name}: #{ex.message}")
Sidekiq.logger.warn(ex.backtrace.join("\n")) unless ex.backtrace.nil?
2014-02-24 23:47:44 -05:00
end
Sidekiq.error_handlers << Sidekiq::ExceptionHandler::Logger.new
end
def handle_exception(ex, ctx = {})
2014-02-24 23:47:44 -05:00
Sidekiq.error_handlers.each do |handler|
handler.call(ex, ctx)
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?
2014-02-24 23:47:44 -05:00
end
end
end
end