I have the following interface and class:
public void ConfigureServices(IServiceCollection services)
{
...
services.AddSingleton<IExceptionManager, ExceptionManager>();
...
}
Now how do I inject IExceptionManager in Asp.net Core ExceptionHandler middleware ?
app.UseExceptionHandler(a => a.Run(async context =>
{
var exceptionHandlerPathFeature = context.Features.Get<IExceptionHandlerPathFeature>();
var exception = exceptionHandlerPathFeature.Error;
//how to define myExceptionManager as IExceptionManager
await context.Response.WriteAsJsonAsync(myExceptionManager.Manage(exception));
}));