From fbcc941e3683cf02ead1aebb9f3de695a301b739 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Wed, 3 Mar 2021 19:28:11 +0100 Subject: update default error-handling to optimize visualization --- .../impl/idp/controller/AbstractController.java | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl') diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java index 0479a8c5..b05d8df0 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java @@ -26,7 +26,6 @@ import javax.annotation.Nullable; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.text.StringEscapeUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -96,11 +95,11 @@ public abstract class AbstractController { protAuthService.handleErrorNoRedirect(e, req, resp, true); } catch (final EaafException e1) { + log.warn("ErrorHandling failed with error: ", e.getMessage(), e); log.warn("Can NOT handle an 'EAAFException'. Forwarding to generic error ... ", e); ioExceptionHandler(resp, e); } - } /** @@ -110,20 +109,23 @@ public abstract class AbstractController { * This handler wrote an internal server error into http response *

* - * @param resp http response - * @param exception exception + * @param req http request + * @param resp http response + * @param e Catched exception * @throws IOException In case of an internal error. */ @ExceptionHandler({ Exception.class }) - public void genericExceptionHandler(final HttpServletResponse resp, final Exception exception) - throws IOException { - log.error("Internel Server Error.", exception); - resp.setContentType(EaafConstants.CONTENTTYPE_HTML_UTF8); - resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Internal Server Error!" - + "(Errorcode=9199" + " | Description=" - + StringEscapeUtils.escapeHtml4(StringEscapeUtils.escapeEcmaScript(exception.getMessage())) - + ")"); + public void genericExceptionHandler(final HttpServletRequest req, final HttpServletResponse resp, + final Exception e) throws IOException { + try { + protAuthService.handleErrorNoRedirect(e, req, resp, true); + + } catch (final EaafException e1) { + log.warn("ErrorHandling failed with error: ", e.getMessage(), e); + log.error("Can NOT handle a generic 'Exception'. Forwarding to generic error ... ", e); + ioExceptionHandler(resp, e); + } } /** -- cgit v1.2.3