diff --git a/app/src/main/java/it/chalmers/gamma/adapter/primary/web/GammaErrorController.java b/app/src/main/java/it/chalmers/gamma/adapter/primary/web/GammaErrorController.java index b5d974e7d..4558e06cc 100644 --- a/app/src/main/java/it/chalmers/gamma/adapter/primary/web/GammaErrorController.java +++ b/app/src/main/java/it/chalmers/gamma/adapter/primary/web/GammaErrorController.java @@ -4,6 +4,8 @@ import jakarta.servlet.RequestDispatcher; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.web.servlet.error.ErrorController; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; @@ -14,6 +16,8 @@ @Controller public class GammaErrorController implements ErrorController { + private static final Logger LOGGER = LoggerFactory.getLogger(GammaErrorController.class); + @GetMapping("/error") public ModelAndView handleRuntimeException( @RequestHeader(value = "HX-Request", required = false) boolean htmxRequest, @@ -24,6 +28,12 @@ public ModelAndView handleRuntimeException( int statusCode = statusCodeString == null ? 500 : Integer.parseInt(statusCodeString.toString()); Exception exception = (Exception) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION); + if (exception == null) { + LOGGER.error("error, but no exception..."); + } else { + LOGGER.error("Caught error, rendering error page...", exception); + } + String page = "pages/error"; if (HttpStatus.valueOf(statusCode) == HttpStatus.NOT_FOUND) {