From 77f33c319be489a13f23e6056ff2efc157d85ee3 Mon Sep 17 00:00:00 2001 From: "chris.boulton" Date: Sun, 27 Mar 2011 19:18:16 +1100 Subject: [PATCH] Move trigger call for onFailure in to ->fail(), so it can catch PHP errors --- lib/Resque/Job.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/Resque/Job.php b/lib/Resque/Job.php index d2023c5..9d674f5 100644 --- a/lib/Resque/Job.php +++ b/lib/Resque/Job.php @@ -188,15 +188,6 @@ class Resque_Job catch(Resque_Job_DontPerform $e) { return false; } - // Catch any other exception and raise the onFailure event. Rethrow - // the exception - catch(Exception $e) { - Resque_Event::trigger('onFailure', array( - 'exception' => $e, - 'job' => $this, - )); - throw $e; - } return true; } @@ -206,6 +197,11 @@ class Resque_Job */ public function fail($exception) { + Resque_Event::trigger('onFailure', array( + 'exception' => $exception, + 'job' => $this, + )); + $this->updateStatus(Resque_Job_Status::STATUS_FAILED); require_once dirname(__FILE__) . '/Failure.php'; Resque_Failure::create(