refactor: Projektdateien migriert. Cloud-NuGet-Pakete durch lokale NuGet-Projekte ersetzt.

This commit is contained in:
Developer 02
2024-08-01 18:44:39 +02:00
parent 0d82f7af6f
commit 62ddd4873f
206 changed files with 10927 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
using HRD.AppLogger;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Hosting;
namespace HRD.WebApi.Helpers
{
public static class ExceptionExtension
{
public static void AddCustomExceptionHandling(this IApplicationBuilder app)
{
app.UseExceptionHandler(errorApp =>
{
errorApp.Run(async context =>
{
context.Response.StatusCode = StatusCodes.Status500InternalServerError;
context.Response.ContentType = "application/json";
var errorFeature = context.Features.Get<IExceptionHandlerFeature>();
if (errorFeature != null)
{
HttpErrorDetails customError = new HttpErrorDetails
{
URI = context.Request.Path.ToUriComponent(),
Status = context.Response.StatusCode,
Detail = errorFeature.Error.Message
};
ILoggerManager logger = new LoggerManager();
logger.LogException(errorFeature.Error, null, customError.URI);
await context.Response.WriteAsync(customError.ToJsonString()).ConfigureAwait(false);
}
});
});
}
}
}