Permalink
Browse files

play nicer; perhaps jobs may want to raise in on_failure hook to avoi…

…d reporting
  • Loading branch information...
1 parent e8ef7fe commit cea58cce6ada94c75369ab9be2715cb389199c08 @yaauie yaauie committed with steveklabnik Nov 23, 2011
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/resque/job.rb
View
9 lib/resque/job.rb
@@ -166,6 +166,13 @@ def payload_class
@payload_class ||= constantize(@payload['class'])
end
+ # returns true if payload_class does not raise NameError
+ def has_payload_class?
+ payload_class != Object
+ rescue NameError
+ false
+ end
+
# Returns an array of args represented in this job's payload.
def args
@payload['args']
@@ -174,7 +181,7 @@ def args
# Given an exception object, hands off the needed parameters to
# the Failure module.
def fail(exception)
- run_failure_hooks(exception) rescue nil
+ run_failure_hooks(exception) if has_payload_class?
Failure.create \
:payload => payload,
:exception => exception,

0 comments on commit cea58cc

Please sign in to comment.