oi-metrology/Server/Controllers/ErrorHandlerController.cs
Mike Phares 5c9f0d1aff Remove with Text
Remove GetEngineeringSpcReview
Better error message
EnforceCodeStyleInBuild
NginxFileSystem
Remove Reactors and Working Directory
AppSettings
Delete self contained Thunder Tests
Back to .net8.0
api/v4/InfinityQS
ApiExplorerSettings
Wafer Counter
2024-04-15 13:13:55 -07:00

31 lines
916 B
C#

using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc;
namespace OI.Metrology.Server.Controllers;
[Route("/error")]
public class ErrorHandlerController : Controller
{
private readonly ILogger _Logger;
public ErrorHandlerController(ILogger<ErrorHandlerController> logger) => _Logger = logger;
[ApiExplorerSettings(IgnoreApi = true)]
public IActionResult Index()
{
IExceptionHandlerFeature? error = HttpContext.Features.Get<IExceptionHandlerFeature>();
if (error is null)
{
return Redirect("~/");
}
else
{
_Logger.LogError("Unhandled exception: " + error.Error.ToString());
dynamic r = new
{
Message = error.Error is null ? "Error" : error.Error.Message
};
return StatusCode(StatusCodes.Status500InternalServerError, r);
}
}
}