From 822c67482cc00ac52d571eb77004d0af8b6fce76 Mon Sep 17 00:00:00 2001 From: "453530270@qq.com" Date: Mon, 7 Oct 2024 17:19:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/ExceptionHandle.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/app/ExceptionHandle.php b/app/ExceptionHandle.php index 9b1c662..5a358e0 100644 --- a/app/ExceptionHandle.php +++ b/app/ExceptionHandle.php @@ -34,20 +34,10 @@ class ExceptionHandle extends Handle * @param Throwable $exception * @return void */ - public function report(Throwable $exception): Response + public function report(Throwable $exception): void { - // 手动触发的异常 BaseException - if ($e instanceof BaseException) { - $this->status = $e->status; - $this->message = $e->message; - $this->data = $e->data; - $extend = property_exists($e, 'extend') ? $e->extend : []; - return $this->output($extend); - }else{ - // 使用内置的方式记录异常日志 - parent::report($exception); - } - + // 使用内置的方式记录异常日志 + parent::report($exception); } /** @@ -61,7 +51,14 @@ class ExceptionHandle extends Handle public function render($request, Throwable $e): Response { // 添加自定义异常处理机制 - + // 手动触发的异常 BaseException + if ($e instanceof BaseException) { + $this->status = $e->status; + $this->message = $e->message; + $this->data = $e->data; + $extend = property_exists($e, 'extend') ? $e->extend : []; + return $this->output($extend); + } // 其他错误交给系统处理 return parent::render($request, $e); }