2012-07-31 11:43:09 -04:00
|
|
|
module Sidekiq
|
|
|
|
module ExceptionHandler
|
|
|
|
|
2013-08-25 15:59:33 -04:00
|
|
|
def handle_exception(ex, ctxHash)
|
|
|
|
Sidekiq.logger.warn ctxHash
|
2012-08-02 23:46:06 -04:00
|
|
|
Sidekiq.logger.warn ex
|
|
|
|
Sidekiq.logger.warn ex.backtrace.join("\n")
|
2012-10-28 16:24:01 -04:00
|
|
|
# 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
|
2013-08-25 15:59:33 -04:00
|
|
|
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)
|
2012-07-31 11:43:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2013-08-25 15:59:33 -04:00
|
|
|
def send_to_airbrake(hash, ex)
|
|
|
|
::Airbrake.notify_or_ignore(ex, :parameters => hash)
|
2012-07-31 11:43:09 -04:00
|
|
|
end
|
|
|
|
|
2013-08-25 15:59:33 -04:00
|
|
|
def send_to_honeybadger(hash, ex)
|
|
|
|
::Honeybadger.notify_or_ignore(ex, :parameters => hash)
|
2012-10-26 23:33:54 -04:00
|
|
|
end
|
|
|
|
|
2013-08-25 15:59:33 -04:00
|
|
|
def send_to_exceptional(hash, ex)
|
2012-07-31 11:43:09 -04:00
|
|
|
if ::Exceptional::Config.should_send_to_api?
|
2013-08-25 15:59:33 -04:00
|
|
|
::Exceptional.context(hash)
|
2012-07-31 11:43:09 -04:00
|
|
|
::Exceptional::Remote.error(::Exceptional::ExceptionData.new(ex))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-25 15:59:33 -04:00
|
|
|
def send_to_exception_notifier(hash, ex)
|
|
|
|
::ExceptionNotifier.notify_exception(ex, :data => {:message => hash})
|
2012-07-31 11:43:09 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|