mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Merge pull request #1234 from musicglue/nil_exception_backtrace
don't fail when handling an exception with a nil backtrace
This commit is contained in:
commit
7de05d328c
2 changed files with 15 additions and 1 deletions
|
@ -4,7 +4,7 @@ module Sidekiq
|
|||
def handle_exception(ex, ctxHash={})
|
||||
Sidekiq.logger.warn(ctxHash) if !ctxHash.empty?
|
||||
Sidekiq.logger.warn ex
|
||||
Sidekiq.logger.warn ex.backtrace.join("\n")
|
||||
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:
|
||||
|
|
|
@ -37,6 +37,20 @@ class TestExceptionHandler < Sidekiq::Test
|
|||
assert_match /Something didn't work!/, log[1], "didn't include the exception message"
|
||||
assert_match /test\/test_exception_handler.rb/, log[2], "didn't include the backtrace"
|
||||
end
|
||||
|
||||
describe "when the exception does not have a backtrace" do
|
||||
it "does not fail" do
|
||||
exception = ExceptionHandlerTestException.new
|
||||
assert_nil exception.backtrace
|
||||
|
||||
begin
|
||||
Component.new.handle_exception exception
|
||||
pass
|
||||
rescue => e
|
||||
flunk "failed handling a nil backtrace"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "with fake Airbrake" do
|
||||
|
|
Loading…
Add table
Reference in a new issue