feat:添加异常过滤器

This commit is contained in:
xiaolipro 2025-07-29 15:52:53 +08:00
parent 17aa5a8b7f
commit ec0acc2421
3 changed files with 16 additions and 1 deletions

View File

@ -57,6 +57,8 @@ public class InterfaceForwardApiModule : FakeModule
await next.Invoke(); await next.Invoke();
}); });
app.UseFakeExceptionHandling();
// Add Aspire default endpoints. // Add Aspire default endpoints.
app.MapDefaultEndpoints(); app.MapDefaultEndpoints();
app.MapControllers(); app.MapControllers();

View File

@ -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;
}
}

View File

@ -18,6 +18,7 @@ namespace InterfaceForward.Application.Services;
/// </summary> /// </summary>
[ApiExplorerSettings(GroupName = "接口转发服务")] [ApiExplorerSettings(GroupName = "接口转发服务")]
[TypeFilter(typeof(ForwardAuthorizeFilter))] [TypeFilter(typeof(ForwardAuthorizeFilter))]
[TypeFilter(typeof(ForwardExceptionFilter))]
[AllowAnonymous] [AllowAnonymous]
[Route("InterfaceForward")] [Route("InterfaceForward")]
public class InterfaceForwardService : ApplicationService, IInterfaceForwardService public class InterfaceForwardService : ApplicationService, IInterfaceForwardService