diff --git a/lib/sneakers/worker.rb b/lib/sneakers/worker.rb index 7ea61d4..90fc8d2 100644 --- a/lib/sneakers/worker.rb +++ b/lib/sneakers/worker.rb @@ -76,7 +76,7 @@ def process_work(delivery_info, metadata, msg, handler) end res = block_to_call.call(deserialized_msg, delivery_info, metadata, handler) end - rescue SignalException, SystemExit + rescue SignalException, SystemExit, Bunny::Exception # ServerEngine handles these exceptions, so they are not expected to be raised within the worker. # Nevertheless, they are listed here to ensure that they are not caught by the rescue block below. raise diff --git a/spec/sneakers/worker_spec.rb b/spec/sneakers/worker_spec.rb index ea19fc5..7587898 100644 --- a/spec/sneakers/worker_spec.rb +++ b/spec/sneakers/worker_spec.rb @@ -446,6 +446,14 @@ def work(msg) w.do_work(header, nil, "msg", handler) end + it "should not catch bunny exceptions" do + w = DummyWorker.new(@queue, TestPool.new) + mock(w).work("msg").once{ raise Bunny::Exception } + assert_raises(Bunny::Exception) do + w.do_work(nil, nil, "msg", nil) + end + end + it "should log exceptions from workers" do handler = Object.new header = Object.new