From 5351657cadc6de2ed006f5aaf1bcea2f5bfd5ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=81=B0=E7=81=B0?= Date: Fri, 14 Oct 2022 00:31:57 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=85=A8=E5=B1=80=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=99=A8=E5=8F=8A=E8=BF=87=E6=BB=A4=E5=99=A8=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=AD=98=E5=82=A8=E5=90=8D=E7=A7=B0=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=E6=9B=B4?= =?UTF-8?q?=E5=8A=A0=E8=AF=A6=E7=BB=86=E7=9B=B4=E8=A7=82=EF=BC=8C=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E4=BF=AE=E6=94=B9=E7=B1=BB=E5=91=BD=E5=90=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CoreCms.Net.Filter/GlobalExceptionsFilterForAdmin.cs | 2 +- CoreCms.Net.Filter/GlobalExceptionsFilterForClent.cs | 2 +- ...iddForAdmin.cs => ExceptionHandlerMiddlewareForAdmin.cs} | 6 +++--- ...iddForClent.cs => ExceptionHandlerMiddlewareForClent.cs} | 6 +++--- CoreCms.Net.Middlewares/MiddlewareHelpers.cs | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) rename CoreCms.Net.Middlewares/{ExceptionHandlerMiddForAdmin.cs => ExceptionHandlerMiddlewareForAdmin.cs} (92%) rename CoreCms.Net.Middlewares/{ExceptionHandlerMiddForClent.cs => ExceptionHandlerMiddlewareForClent.cs} (92%) diff --git a/CoreCms.Net.Filter/GlobalExceptionsFilterForAdmin.cs b/CoreCms.Net.Filter/GlobalExceptionsFilterForAdmin.cs index f992cf59..e3dfee57 100644 --- a/CoreCms.Net.Filter/GlobalExceptionsFilterForAdmin.cs +++ b/CoreCms.Net.Filter/GlobalExceptionsFilterForAdmin.cs @@ -36,7 +36,7 @@ namespace CoreCms.Net.Filter public void OnException(ExceptionContext context) { - NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.Web, "全局异常", "全局捕获异常", context.Exception); + NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.Web, "全局异常", context.Exception.Message, context.Exception); HttpStatusCode status = HttpStatusCode.InternalServerError; diff --git a/CoreCms.Net.Filter/GlobalExceptionsFilterForClent.cs b/CoreCms.Net.Filter/GlobalExceptionsFilterForClent.cs index 0ff643a0..0c4e2a13 100644 --- a/CoreCms.Net.Filter/GlobalExceptionsFilterForClent.cs +++ b/CoreCms.Net.Filter/GlobalExceptionsFilterForClent.cs @@ -36,7 +36,7 @@ namespace CoreCms.Net.Filter public void OnException(ExceptionContext context) { - NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.Web, "全局异常", "全局捕获异常", context.Exception); + NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.Web, "全局异常", context.Exception.Message, context.Exception); HttpStatusCode status = HttpStatusCode.InternalServerError; diff --git a/CoreCms.Net.Middlewares/ExceptionHandlerMiddForAdmin.cs b/CoreCms.Net.Middlewares/ExceptionHandlerMiddlewareForAdmin.cs similarity index 92% rename from CoreCms.Net.Middlewares/ExceptionHandlerMiddForAdmin.cs rename to CoreCms.Net.Middlewares/ExceptionHandlerMiddlewareForAdmin.cs index 77a7046e..06b0977d 100644 --- a/CoreCms.Net.Middlewares/ExceptionHandlerMiddForAdmin.cs +++ b/CoreCms.Net.Middlewares/ExceptionHandlerMiddlewareForAdmin.cs @@ -26,11 +26,11 @@ namespace CoreCms.Net.Middlewares; /// /// 异常错误统一返回记录 /// -public class ExceptionHandlerMiddForAdmin +public class ExceptionHandlerMiddlewareForAdmin { private readonly RequestDelegate _next; - public ExceptionHandlerMiddForAdmin(RequestDelegate next) + public ExceptionHandlerMiddlewareForAdmin(RequestDelegate next) { _next = next; } @@ -50,7 +50,7 @@ public class ExceptionHandlerMiddForAdmin private async Task HandleExceptionAsync(HttpContext context, Exception ex) { if (ex == null) return; - NLogUtil.WriteAll(LogLevel.Error, LogType.Web, "全局捕获异常", "全局捕获异常", new Exception("全局捕获异常", ex)); + NLogUtil.WriteAll(LogLevel.Error, LogType.Web, "全局捕获异常", ex.Message, ex); await WriteExceptionAsync(context, ex).ConfigureAwait(false); } diff --git a/CoreCms.Net.Middlewares/ExceptionHandlerMiddForClent.cs b/CoreCms.Net.Middlewares/ExceptionHandlerMiddlewareForClent.cs similarity index 92% rename from CoreCms.Net.Middlewares/ExceptionHandlerMiddForClent.cs rename to CoreCms.Net.Middlewares/ExceptionHandlerMiddlewareForClent.cs index 6acf793d..b5d5219a 100644 --- a/CoreCms.Net.Middlewares/ExceptionHandlerMiddForClent.cs +++ b/CoreCms.Net.Middlewares/ExceptionHandlerMiddlewareForClent.cs @@ -26,12 +26,12 @@ namespace CoreCms.Net.Middlewares; /// /// 异常错误统一返回记录 /// -public class ExceptionHandlerMiddForClent +public class ExceptionHandlerMiddlewareForClent { private readonly RequestDelegate _next; - public ExceptionHandlerMiddForClent(RequestDelegate next) + public ExceptionHandlerMiddlewareForClent(RequestDelegate next) { _next = next; } @@ -52,7 +52,7 @@ public class ExceptionHandlerMiddForClent { if (ex == null) return; - NLogUtil.WriteAll(LogLevel.Error, LogType.ApiRequest, "全局捕获异常", "全局捕获异常", new Exception("全局捕获异常", ex)); + NLogUtil.WriteAll(LogLevel.Error, LogType.ApiRequest, "全局捕获异常", ex.Message, ex); await WriteExceptionAsync(context, ex).ConfigureAwait(false); } diff --git a/CoreCms.Net.Middlewares/MiddlewareHelpers.cs b/CoreCms.Net.Middlewares/MiddlewareHelpers.cs index 76eda593..1786f00e 100644 --- a/CoreCms.Net.Middlewares/MiddlewareHelpers.cs +++ b/CoreCms.Net.Middlewares/MiddlewareHelpers.cs @@ -38,7 +38,7 @@ namespace CoreCms.Net.Middlewares /// public static IApplicationBuilder UseExceptionHandlerMiddForAdmin(this IApplicationBuilder app) { - return app.UseMiddleware(); + return app.UseMiddleware(); } /// @@ -48,7 +48,7 @@ namespace CoreCms.Net.Middlewares /// public static IApplicationBuilder UseExceptionHandlerMiddForClent(this IApplicationBuilder app) { - return app.UseMiddleware(); + return app.UseMiddleware(); } ///