Using Laravel 5.1's Queues, I'm throwing an exception when a job fails.
throw new \Exception('No luck');
As Laravel recommends when dealing with failed jobs, I'm "catching" the exception in the AppServiceProvider
, and using that to send our team an email.
public function boot()
{
Queue::failing(function ($connection, $job, $data) {
$info['data'] = $data;
\Mail::send('emails.jobs.failed', $info, function($message) {
$message->to('test@email.com')->subject('Job failed');
});
});
}
Within the email, I would like to place the exception's message (in this case "No luck."). But I can't figure out how to pass that along to Queue::failing().
Any ideas?