This commit is contained in:
2026-08-05 10:31:38 +08:00
parent 83c0865272
commit b4e5e98353
3 changed files with 20 additions and 20 deletions

View File

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