feat(API): add global exception handler
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user