This commit is contained in:
2026-08-05 11:06:20 +08:00
parent b4e5e98353
commit 8380b8797b
4 changed files with 24 additions and 24 deletions

View File

@@ -56,17 +56,17 @@ class ExceptionHandle extends Handle
{
// 验证器异常
if ($e instanceof ValidateException) {
return $this->error(422, $e->getError()); // 验证器没通过
return $this->error($e->getError(), [], 422); // 验证器没通过
};
// 请求异常
if ($e instanceof HttpException) {
return $this->error($e->getStatusCode(), $e->getMessage());
return $this->error($e->getMessage(), [], $e->getStatusCode());
};
// 处理【自定义业务异常】(在 Service 层主动 throw 的错误)
if ($e instanceof \think\Exception) {
return $this->error($e->getCode() ?: 400, $e->getMessage());
return $this->error($e->getMessage(), [], $e->getCode() ?: 400);
}
// 其他错误交给系统处理