28 lines
526 B
C#
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;
|
|
}
|
|
}
|
|
}
|