diff --git a/lib/sidekiq/exception_handler.rb b/lib/sidekiq/exception_handler.rb index cec11277..d468c692 100644 --- a/lib/sidekiq/exception_handler.rb +++ b/lib/sidekiq/exception_handler.rb @@ -5,35 +5,7 @@ module Sidekiq 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) - 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 diff --git a/test/test_exception_handler.rb b/test/test_exception_handler.rb index 43bd388a..6bf129c7 100644 --- a/test/test_exception_handler.rb +++ b/test/test_exception_handler.rb @@ -53,86 +53,4 @@ class TestExceptionHandler < Sidekiq::Test end end - describe "with fake Airbrake" do - before do - ::Airbrake = Minitest::Mock.new - end - - after do - Object.send(:remove_const, "Airbrake") # HACK should probably inject Airbrake etc into this class in the future - end - - it "notifies Airbrake" do - ::Airbrake.expect(:notify_or_ignore,nil,[TEST_EXCEPTION,:parameters => { :a => 1 }]) - Component.new.invoke_exception(:a => 1) - ::Airbrake.verify - end - end - - describe "with fake Honeybadger" do - before do - ::Honeybadger = Minitest::Mock.new - end - - after do - Object.send(:remove_const, "Honeybadger") # HACK should probably inject Honeybadger etc into this class in the future - end - - it "notifies Honeybadger" do - ::Honeybadger.expect(:notify_or_ignore,nil,[TEST_EXCEPTION,:parameters => { :a => 1 }]) - Component.new.invoke_exception(:a => 1) - ::Honeybadger.verify - end - end - - describe "with fake ExceptionNotifier" do - before do - ::ExceptionNotifier = MiniTest::Mock.new - end - - after do - Object.send(:remove_const, "ExceptionNotifier") - end - - it "notifies ExceptionNotifier" do - ::ExceptionNotifier.expect(:notify_exception,true,[TEST_EXCEPTION, :data => { :message => { :b => 2 } }]) - Component.new.invoke_exception(:b => 2) - ::ExceptionNotifier.verify - end - end - - describe "with fake Exceptional" do - before do - ::Exceptional = Class.new do - - def self.context(msg) - @msg = msg - end - - def self.check_context - @msg - end - end - - ::Exceptional::Config = Minitest::Mock.new - ::Exceptional::Remote = Minitest::Mock.new - ::Exceptional::ExceptionData = Minitest::Mock.new - end - - after do - Object.send(:remove_const, "Exceptional") - end - - it "notifies Exceptional" do - ::Exceptional::Config.expect(:should_send_to_api?,true) - exception_data = Object.new - ::Exceptional::Remote.expect(:error,nil,[exception_data]) - ::Exceptional::ExceptionData.expect(:new,exception_data,[TEST_EXCEPTION]) - Component.new.invoke_exception(:c => 3) - assert_equal({:c => 3},::Exceptional.check_context,"did not record arguments properly") - ::Exceptional::Config.verify - ::Exceptional::Remote.verify - ::Exceptional::ExceptionData.verify - end - end end