diff --git a/Biwen.QuickApi.DemoWeb/CustomExceptionHandler.cs b/Biwen.QuickApi.DemoWeb/CustomExceptionHandler.cs new file mode 100644 index 00000000..286f4101 --- /dev/null +++ b/Biwen.QuickApi.DemoWeb/CustomExceptionHandler.cs @@ -0,0 +1,21 @@ + +namespace Biwen.QuickApi.DemoWeb +{ + /// + /// 自定义异常处理 + /// + public class CustomExceptionHandler : IQuickApiExceptionHandler + { + private readonly ILogger _logger; + public CustomExceptionHandler(ILogger logger) + { + _logger = logger; + } + + public Task HandleAsync(Exception exception) + { + _logger.LogError(exception, "QuickApi异常"); + return Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/Biwen.QuickApi.DemoWeb/Program.cs b/Biwen.QuickApi.DemoWeb/Program.cs index 09c36952..5c09bcb4 100644 --- a/Biwen.QuickApi.DemoWeb/Program.cs +++ b/Biwen.QuickApi.DemoWeb/Program.cs @@ -89,6 +89,9 @@ //ҪԶ쳣ظʽ builder.Services.AddSingleton(); +//Զ쳣 +builder.Services.AddScoped(); + var app = builder.Build();