diff --git a/src/WebApi/Controllers/ErrorController.cs b/src/WebApi/Controllers/ErrorController.cs index 509d66ff1..c4ecb02af 100644 --- a/src/WebApi/Controllers/ErrorController.cs +++ b/src/WebApi/Controllers/ErrorController.cs @@ -6,7 +6,7 @@ namespace JJMasterData.WebApi.Controllers; [ApiController] [ApiExplorerSettings(IgnoreApi = true)] -public class ErrorController : ControllerBase +public class ErrorController(ILogger logger) : ControllerBase { [Route("/Error")] public IActionResult HandleError() @@ -14,8 +14,12 @@ public IActionResult HandleError() var exceptionHandlerFeature = HttpContext.Features.Get()!; - var responseLetter = ExceptionManager.GetResponse(exceptionHandlerFeature.Error); + var error = exceptionHandlerFeature.Error; + + var responseLetter = ExceptionManager.GetResponse(error); + logger.LogCritical(error, "Unexpected error at WebApi."); + return new ObjectResult(responseLetter) { StatusCode = responseLetter.Status diff --git a/src/WebApi/WebApi.csproj b/src/WebApi/WebApi.csproj index 5edc2c624..ff674e143 100644 --- a/src/WebApi/WebApi.csproj +++ b/src/WebApi/WebApi.csproj @@ -11,6 +11,7 @@ JJMasterData.WebApi true JJMasterData.WebApi + JJMasterData.WebApi true library false