Files
example-csharp-app/ErrorLogMiddleware.cs
T
2026-09-25 08:05:46 +03:00

28 lines
526 B
C#

using System;
namespace example_csharp_app;
public class ErrorLogMiddleware
{
private readonly RequestDelegate _next;
public ErrorLogMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(HttpContext httpContext, IConfiguration configuration)
{
try
{
await _next(httpContext);
return;
}
catch (Exception)
{
// todo: logme
httpContext.Response.StatusCode = 500;
}
}
}