Skip to content

Commit 5ba33f5

Browse files
yaauiesteveklabnik
authored andcommitted
play nicer; perhaps jobs may want to raise in on_failure hook to avoid reporting
1 parent 07f49f9 commit 5ba33f5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/resque/job.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ def payload_class
166166
@payload_class ||= constantize(@payload['class'])
167167
end
168168

169+
# returns true if payload_class does not raise NameError
170+
def has_payload_class?
171+
payload_class != Object
172+
rescue NameError
173+
false
174+
end
175+
169176
# Returns an array of args represented in this job's payload.
170177
def args
171178
@payload['args']
@@ -174,7 +181,7 @@ def args
174181
# Given an exception object, hands off the needed parameters to
175182
# the Failure module.
176183
def fail(exception)
177-
run_failure_hooks(exception) rescue nil
184+
run_failure_hooks(exception) if has_payload_class?
178185
Failure.create \
179186
:payload => payload,
180187
:exception => exception,

0 commit comments

Comments
 (0)