From ec0acc24219c8bb5c7772ffd2aa5fef3c102e704 Mon Sep 17 00:00:00 2001 From: xiaolipro <2357729423@qq.com> Date: Tue, 29 Jul 2025 15:52:53 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=B7=BB=E5=8A=A0=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E8=BF=87=E6=BB=A4=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InterfaceForwardApiModule.cs | 2 ++ .../Filters/ExceptionNotifier.cs | 12 ++++++++++++ .../Services/InterfaceForwardService.cs | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/InterfaceForward.Application/Filters/ExceptionNotifier.cs diff --git a/src/InterfaceForward.Api/InterfaceForwardApiModule.cs b/src/InterfaceForward.Api/InterfaceForwardApiModule.cs index 97c8a5a..e48d7ac 100644 --- a/src/InterfaceForward.Api/InterfaceForwardApiModule.cs +++ b/src/InterfaceForward.Api/InterfaceForwardApiModule.cs @@ -57,6 +57,8 @@ public class InterfaceForwardApiModule : FakeModule await next.Invoke(); }); + app.UseFakeExceptionHandling(); + // Add Aspire default endpoints. app.MapDefaultEndpoints(); app.MapControllers(); diff --git a/src/InterfaceForward.Application/Filters/ExceptionNotifier.cs b/src/InterfaceForward.Application/Filters/ExceptionNotifier.cs new file mode 100644 index 0000000..8f188af --- /dev/null +++ b/src/InterfaceForward.Application/Filters/ExceptionNotifier.cs @@ -0,0 +1,12 @@ +using Fake.DependencyInjection; +using Fake.ExceptionHandling; + +namespace InterfaceForward.Application.Filters; + +public class ExceptionNotifier: IExceptionNotifier, ITransientDependency +{ + public Task NotifyAsync(ExceptionNotificationContext context) + { + return Task.CompletedTask; + } +} \ No newline at end of file diff --git a/src/InterfaceForward.Application/Services/InterfaceForwardService.cs b/src/InterfaceForward.Application/Services/InterfaceForwardService.cs index 4f957ac..3416db3 100644 --- a/src/InterfaceForward.Application/Services/InterfaceForwardService.cs +++ b/src/InterfaceForward.Application/Services/InterfaceForwardService.cs @@ -17,7 +17,8 @@ namespace InterfaceForward.Application.Services; /// 接口转发服务 /// [ApiExplorerSettings(GroupName = "接口转发服务")] -[TypeFilter(typeof(ForwardAuthorizeFilter))] +[TypeFilter(typeof(ForwardAuthorizeFilter))] +[TypeFilter(typeof(ForwardExceptionFilter))] [AllowAnonymous] [Route("InterfaceForward")] public class InterfaceForwardService : ApplicationService, IInterfaceForwardService