feat(API): add global exception handler
This commit is contained in:
parent
13acf6de08
commit
78f2788388
@ -16,6 +16,7 @@ using WorkFlow.API;
|
||||
using Microsoft.Extensions.Options;
|
||||
using DigitalData.Core.Abstractions.Security.Extensions;
|
||||
using DigitalData.UserManager.DependencyInjection;
|
||||
using DigitalData.Core.Exceptions.Middleware;
|
||||
|
||||
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||
logger.Info("Logging initialized.");
|
||||
@ -56,6 +57,8 @@ try
|
||||
Claims = user.ToClaimList().ToDictionary(claim => claim.Type, claim => claim.Value as object)
|
||||
});
|
||||
|
||||
builder.Services.ConfigureGlobalExceptionHandler();
|
||||
|
||||
bool disableAPIKeyAuth = config.GetValue<bool>("DisableAPIKeyAuth");
|
||||
if (disableAPIKeyAuth)
|
||||
builder.Services.AddAPIKeyAuth(new APIKeyAuthOptions());
|
||||
@ -165,6 +168,8 @@ try
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.UseGlobalExceptionHandler();
|
||||
|
||||
app.Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DigitalData.Auth.Client" Version="1.3.7" />
|
||||
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.0.0" />
|
||||
<PackageReference Include="DigitalData.Core.Exceptions.Middleware" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.20" />
|
||||
<PackageReference Include="NLog" Version="5.3.4" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.14" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user