feat(ExceptionHandlingMiddleware): Add to handle exceptions by middleware
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
using WorkFlow.Application;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WorkFlow.Infrastructure;
|
||||
using DigitalData.Auth.Client;
|
||||
using DigitalData.Core.Abstractions.Security.Extensions;
|
||||
using DigitalData.Core.Application;
|
||||
using DigitalData.UserManager.Application.DTOs.User;
|
||||
using DigitalData.UserManager.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using WorkFlow.API.Models;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using NLog;
|
||||
using NLog.Web;
|
||||
using WorkFlow.API;
|
||||
using WorkFlow.API.Extensions;
|
||||
using WorkFlow.API.Filters;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using DigitalData.Auth.Client;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using WorkFlow.API;
|
||||
using Microsoft.Extensions.Options;
|
||||
using DigitalData.Core.Abstractions.Security.Extensions;
|
||||
using DigitalData.UserManager.DependencyInjection;
|
||||
using DigitalData.Core.Exceptions.Middleware;
|
||||
using WorkFlow.API.Middleware;
|
||||
using WorkFlow.API.Models;
|
||||
using WorkFlow.Application;
|
||||
using WorkFlow.Infrastructure;
|
||||
|
||||
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||
logger.Info("Logging initialized.");
|
||||
@@ -57,8 +57,6 @@ 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());
|
||||
@@ -153,6 +151,8 @@ try
|
||||
|
||||
lazyProvider.Factory = () => app.Services;
|
||||
|
||||
app.UseMiddleware<ExceptionHandlingMiddleware>();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Configuration.GetValue<bool>("EnableSwagger"))
|
||||
{
|
||||
@@ -168,8 +168,6 @@ try
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.UseGlobalExceptionHandler();
|
||||
|
||||
app.Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user