【发布时间】:2016-02-19 06:07:02
【问题描述】:
使用 Laravel 5.1 的队列,当作业失败时我会抛出异常。
throw new \Exception('No luck');
正如 Laravel 在 dealing with failed jobs 时建议的那样,我正在“捕捉”AppServiceProvider 中的异常,并使用它向我们的团队发送电子邮件。
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');
});
});
}
在电子邮件中,我想放置异常的消息(在本例中为“不走运。”)。但我不知道如何将它传递给 Queue::failing()。
有什么想法吗?
【问题讨论】:
标签: laravel queue laravel-5.1 ironmq