Compare commits

..

3 Commits

Author SHA1 Message Date
zj
d0acbeea51 update 2026-07-31 08:55:18 +08:00
zj
be71680b2a update 2026-07-31 08:33:23 +08:00
zj
ec64c80563 update 2026-07-31 08:32:26 +08:00
3 changed files with 16 additions and 9 deletions

View File

@@ -1,3 +1,6 @@
# hyperf_micro_service_core_app
app微服务核心库,所有微服务均以本库为基础
app微服务核心库,所有微服务均以本库为基础
### update
composer update dhd/hyperf-micro-service-core

View File

@@ -62,7 +62,7 @@ class GatewayExceptionHandler extends ExceptionHandler
$responseData = [
'code' => $code,
'message' => $message,
'data' => null,
'data' => method_exists($throwable, 'getData') ? $throwable->getData() : null,
];
return $response

View File

@@ -34,16 +34,20 @@ class JsonRpcBusinessExceptionHandler extends ExceptionHandler
$request = Util::get(ServerRequestInterface::class);
// 关键优化:从 Request 属性中动态获取 ID
$id = $request ? $request->getAttribute('request_id', null) : null; // Hyperf 注入的 ID
$isError = !($throwable instanceof BusinessException)
&& !($throwable instanceof ValidateException)
&& !($throwable instanceof RequestException);
$code = $throwable->getCode() ?? 500;
$message = $throwable->getMessage() ?? '服务器内部错误';
if ($isError) {
$code = 500;
$message = '服务器内部错误';
} else {
$code = $throwable->getCode() ?? 500;
$message = $throwable->getMessage() ?? '服务器内部错误';
}
Util::logger()
->setErrorStatus(
!($throwable instanceof BusinessException)
&& !($throwable instanceof ValidateException)
&& !($throwable instanceof RequestException)
)
->setErrorStatus($isError)
->setMessage($message)
->setThrowable($throwable)
->setTraceId($traceId)