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

40 lines
1.3 KiB
Ruby
Raw Normal View History

module Sidekiq
module ExceptionHandler
def handle_exception(ex, ctxHash={})
Sidekiq.logger.warn(ctxHash) if !ctxHash.empty?
Sidekiq.logger.warn ex
Sidekiq.logger.warn ex.backtrace.join("\n") unless ex.backtrace.nil?
# This list of services is getting a bit ridiculous.
# For future error services, please add your own
# middleware like BugSnag does:
# https://github.com/bugsnag/bugsnag-ruby/blob/master/lib/bugsnag/sidekiq.rb
send_to_airbrake(ctxHash, ex) if defined?(::Airbrake)
send_to_honeybadger(ctxHash, ex) if defined?(::Honeybadger)
send_to_exceptional(ctxHash, ex) if defined?(::Exceptional)
send_to_exception_notifier(ctxHash, ex) if defined?(::ExceptionNotifier)
end
private
def send_to_airbrake(hash, ex)
::Airbrake.notify_or_ignore(ex, :parameters => hash)
end
def send_to_honeybadger(hash, ex)
::Honeybadger.notify_or_ignore(ex, :parameters => hash)
2012-10-26 23:33:54 -04:00
end
def send_to_exceptional(hash, ex)
if ::Exceptional::Config.should_send_to_api?
::Exceptional.context(hash)
::Exceptional::Remote.error(::Exceptional::ExceptionData.new(ex))
end
end
def send_to_exception_notifier(hash, ex)
::ExceptionNotifier.notify_exception(ex, :data => {:message => hash})
end
end
end