From e5dd2b81f173b3042e8d56edfe0cfee4ae64ca5f Mon Sep 17 00:00:00 2001 From: zj Date: Wed, 5 Aug 2026 15:24:46 +0800 Subject: [PATCH] update --- .../Handler/GatewayExceptionHandler.php | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Exception/Handler/GatewayExceptionHandler.php b/src/Exception/Handler/GatewayExceptionHandler.php index f9706f1..e5f0370 100644 --- a/src/Exception/Handler/GatewayExceptionHandler.php +++ b/src/Exception/Handler/GatewayExceptionHandler.php @@ -32,25 +32,21 @@ class GatewayExceptionHandler extends ExceptionHandler $this->stopPropagation(); // 阻止异常冒泡 $traceId = $this->getTraceId(); + $isError = !($throwable instanceof BusinessException) + && !($throwable instanceof ValidateException) + && !($throwable instanceof RequestException); - $code = 500; - $message = '服务器内部错误'; - - if (($throwable instanceof BusinessException)) { - $code = $throwable->getCode(); - $message = $throwable->getMessage(); + if ($isError) { + $code = 500; + $message = '服务器内部错误'; } else { - $code = $throwable->getCode() ?: 500; - $message = $throwable->getMessage() ?: '服务异常,请稍后重试'; + $code = $throwable->getCode() ?? 500; + $message = $throwable->getMessage() ?? '服务器内部错误'; } $request = Util::get(RequestInterface::class); Util::logger() - ->setErrorStatus( - !($throwable instanceof BusinessException) - && !($throwable instanceof ValidateException) - && !($throwable instanceof RequestException) - ) + ->setErrorStatus($isError) ->setMessage($message) ->setThrowable($throwable) ->setTraceId($traceId)