【发布时间】:2022-12-20 22:09:02
【问题描述】:
尝试使用自定义异常:
namespace App\Exceptions\Cloud;
use Exception;
class CantConfirmOrder extends Exception
{
public function report()
{
info('test exception');
}
}
但是当我把它扔进修补程序时 - 没有任何内容写入日志:
>>> throw new CantConfirmOrder('test');
[!] Aliasing 'CantConfirmOrder' to 'App\Exceptions\Cloud\CantConfirmOrder' for this Tinker session.
App\Exceptions\Cloud\CantConfirmOrder with message 'test'
处理程序.php:
public function report(Throwable $exception)
{
parent::report($exception);
}
我需要用 try catch 手动调用 report() 吗?我认为它会在我投掷时自动调用。
【问题讨论】: