From fb11a69e92371bb5c34a8757c237dcd2790c65ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=8A=E7=A3=8A?= Date: Mon, 11 Jul 2022 17:31:02 +0800 Subject: [PATCH] feat(Exception): GlobalExceptionFilter supports custom Handler (#84) * doc: Modify the document * chore: GlobalExceptionFilter supports custom Handler --- .../Handlers/GlobalExceptionFilter.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Masa.Utils.Exceptions/Handlers/GlobalExceptionFilter.cs b/src/Masa.Utils.Exceptions/Handlers/GlobalExceptionFilter.cs index 3185f2b..c24e031 100644 --- a/src/Masa.Utils.Exceptions/Handlers/GlobalExceptionFilter.cs +++ b/src/Masa.Utils.Exceptions/Handlers/GlobalExceptionFilter.cs @@ -27,7 +27,14 @@ public MvcGlobalExcetionFilter(IServiceProvider serviceProvider, public void OnException(ExceptionContext context) { var masaExceptionContext = new MasaExceptionContext(context.Exception, context.HttpContext); - _options.ExceptionHandler?.Invoke(masaExceptionContext); + if (_options.ExceptionHandler != null) + { + _options.ExceptionHandler.Invoke(masaExceptionContext); + } + else + { + _masaExceptionHandler?.OnException(masaExceptionContext); + } if (masaExceptionContext.HttpContext.Response.HasStarted) return;