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/middleware/server/exception_handler.rb

39 lines
1 KiB
Ruby
Raw Normal View History

require 'sidekiq/util'
2012-02-08 20:04:19 -05:00
module Sidekiq
module Middleware
module Server
class ExceptionHandler
include Util
def call(*args)
2012-02-08 20:04:19 -05:00
yield
rescue => ex
logger.warn ex
logger.warn ex.backtrace.join("\n")
send_to_airbrake(args[1], ex) if defined?(::Airbrake)
send_to_exceptional(args[1], ex) if defined?(::Exceptional)
send_to_exception_notifier(args[1], ex) if defined?(::ExceptionNotifier)
2012-02-08 20:04:19 -05:00
raise
end
private
def send_to_airbrake(msg, ex)
::Airbrake.notify(ex, :parameters => msg)
2012-02-08 20:04:19 -05:00
end
def send_to_exceptional(msg, ex)
if ::Exceptional::Config.should_send_to_api?
::Exceptional.context(msg)
::Exceptional::Remote.error(::Exceptional::ExceptionData.new(ex))
end
end
def send_to_exception_notifier(msg, ex)
::ExceptionNotifier::Notifier.background_exception_notification(ex, :data => { :message => msg })
end
2012-02-08 20:04:19 -05:00
end
end
end
end