Move trigger call for onFailure in to ->fail(), so it can catch PHP errors

This commit is contained in:
chris.boulton 2011-03-27 19:18:16 +11:00
parent 3245c523c7
commit 77f33c319b

View File

@ -188,15 +188,6 @@ class Resque_Job
catch(Resque_Job_DontPerform $e) { catch(Resque_Job_DontPerform $e) {
return false; 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; return true;
} }
@ -206,6 +197,11 @@ class Resque_Job
*/ */
public function fail($exception) public function fail($exception)
{ {
Resque_Event::trigger('onFailure', array(
'exception' => $exception,
'job' => $this,
));
$this->updateStatus(Resque_Job_Status::STATUS_FAILED); $this->updateStatus(Resque_Job_Status::STATUS_FAILED);
require_once dirname(__FILE__) . '/Failure.php'; require_once dirname(__FILE__) . '/Failure.php';
Resque_Failure::create( Resque_Failure::create(