From 46e8a81346f61593f00ac4269cd5529cc883a35b Mon Sep 17 00:00:00 2001 From: claw_bot Date: Thu, 12 Mar 2026 03:12:32 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=A8=E5=B1=80=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E4=B8=AD=E9=97=B4=E4=BB=B6=E5=91=BD=E5=90=8D=E7=A9=BA?= =?UTF-8?q?=E9=97=B4=E5=86=B2=E7=AA=81=EF=BC=9A=E6=98=BE=E5=BC=8F=E6=8C=87?= =?UTF-8?q?=E5=AE=9AStatusCodes=E4=B8=BAMicrosoft.AspNetCore.Http.StatusCo?= =?UTF-8?q?des?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Middleware/GlobalExceptionMiddleware.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/AssetManager.API/Middleware/GlobalExceptionMiddleware.cs b/AssetManager.API/Middleware/GlobalExceptionMiddleware.cs index eb367fb..e6f0add 100644 --- a/AssetManager.API/Middleware/GlobalExceptionMiddleware.cs +++ b/AssetManager.API/Middleware/GlobalExceptionMiddleware.cs @@ -40,7 +40,7 @@ public class GlobalExceptionMiddleware context.Response.ContentType = "application/json"; var response = new ApiResponse { - code = StatusCodes.Status500InternalServerError, + code = Microsoft.AspNetCore.Http.StatusCodes.Status500InternalServerError, data = null, message = exception.Message }; @@ -50,21 +50,21 @@ public class GlobalExceptionMiddleware { case UnauthorizedAccessException _: context.Response.StatusCode = (int)HttpStatusCode.Unauthorized; - response.code = StatusCodes.Status401Unauthorized; + response.code = Microsoft.AspNetCore.Http.StatusCodes.Status401Unauthorized; response.message = "未授权访问"; break; case ArgumentException _: case InvalidOperationException _: context.Response.StatusCode = (int)HttpStatusCode.BadRequest; - response.code = StatusCodes.Status400BadRequest; + response.code = Microsoft.AspNetCore.Http.StatusCodes.Status400BadRequest; break; case KeyNotFoundException _: context.Response.StatusCode = (int)HttpStatusCode.NotFound; - response.code = StatusCodes.Status404NotFound; + response.code = Microsoft.AspNetCore.Http.StatusCodes.Status404NotFound; break; default: context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; - response.code = StatusCodes.Status500InternalServerError; + response.code = Microsoft.AspNetCore.Http.StatusCodes.Status500InternalServerError; // 生产环境可以隐藏具体错误信息,避免泄露敏感信息 // response.message = "服务器内部错误"; break;