Fatal Exception Handled Twice?
我在app\exceptions\handler里面的report方法里调用我自己的mailable实现报错后发送邮件的功能,但是莫名其妙的每次我测试,都会收到两封邮件,然后我注释掉了我的mailable后,继续测试,我这边查看日志,会出现一模一样的两个错,提了issue,说这事因为error_last_clear()错误被handle了但是没有最后清理掉,这算是bug吗
代码:
public function report(Exception $exception)
{
if ($this->shouldReport($exception)) {
Mail::to('leslie@aliyun.com')->send(new ReportException($exception));
}
parent::report($exception);
}
mailable代码:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Exception;
/**
* Class ReportException
* @package App\Mail
*/
class ReportException extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
* @return void
*/
protected $exception;
/**
* ReportException constructor.
* @param $exception
*/
public function __construct(Exception $exception)
{
$this->exception = $exception;
}
/**
* Build the message.
* @return $this
*/
public function build()
{
return $this->view('mail.error')->with([
'Code' => $this->exception->getCode(),
'Message' => $this->exception->getMessage(),
'File' => $this->exception->getFile(),
'Line' => $this->exception->getLine(),
'Trace' => $this->exception->getTraceAsString()
]);
}
}
推荐文章: