Код: Выделить всё
if (env.IsDevelopment()) {
app.UseExceptionHandler("/api/error/error-local-development");
}
else {
app.UseExceptionHandler("/api/error/error");
}
Код: Выделить всё
[Route("api/error")]
[ApiController]
[ApiExplorerSettings(IgnoreApi = true)]
public class ErrorController : OwnBaseController
{
public ErrorController(IApplicationUserService applicationUserService, ILogger logger, IDiagnosticContext diagnosticContext) : base(applicationUserService, logger, diagnosticContext)
{
}
[Route("error")]
public IActionResult Error()
{
return Problem();
}
[Route("error-local-development")]
public IActionResult ErrorLocalDevelopment([FromServices] IWebHostEnvironment webHostEnvironment)
{
var context = HttpContext.Features.Get();
return Problem(
detail: context.Error.StackTrace,
title: context.Error.Message);
}
}
Подробнее здесь: https://stackoverflow.com/questions/663 ... ot-working