Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Catch errors when handling a failed job #16212

Merged
merged 14 commits into from
Nov 2, 2016
16 changes: 9 additions & 7 deletions src/Illuminate/Queue/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,16 @@ protected function failJob($connectionName, $job, $e)
return;
}

// If the job has failed, we will delete it, call the "failed" method and then call
// an event indicating the job has failed so it can be logged if needed. This is
// to allow every developer to better keep monitor of their failed queue jobs.
$job->delete();

$job->failed($e);
try {
// If the job has failed, we will delete it, call the "failed" method and then call
// an event indicating the job has failed so it can be logged if needed. This is
// to allow every developer to better keep monitor of their failed queue jobs.
$job->delete();

$this->raiseFailedJobEvent($connectionName, $job, $e);
$job->failed($e);
} finally {
$this->raiseFailedJobEvent($connectionName, $job, $e);
}
}

/**
Expand Down