Skip to content

Commit 07f49f9

Browse files
yaauiesteveklabnik
authored andcommitted
fix swallowed failure when job def not found
Conflicts: test/worker_test.rb
1 parent 0f71064 commit 07f49f9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/resque/job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def args
174174
# Given an exception object, hands off the needed parameters to
175175
# the Failure module.
176176
def fail(exception)
177-
run_failure_hooks(exception)
177+
run_failure_hooks(exception) rescue nil
178178
Failure.create \
179179
:payload => payload,
180180
:exception => exception,

test/worker_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
assert_equal('Extra Bad job!', Resque::Failure.all['error'])
2929
end
3030

31+
it "unavailable job definition reports exception and message" do
32+
Resque::Job.create(:jobs, 'NoJobDefinition')
33+
@worker.work(0)
34+
assert_equal 1, Resque::Failure.count, 'failure not reported'
35+
assert_equal('NameError', Resque::Failure.all['exception'])
36+
assert_equal('uninitialized constant NoJobDefinition', Resque::Failure.all['error'])
37+
end
38+
3139
it "does not allow exceptions from failure backend to escape" do
3240
job = Resque::Job.new(:jobs, {})
3341
with_failure_backend BadFailureBackend do

0 commit comments

Comments
 (0)