src/main/java/de/uapcore/lightpit/modules/ErrorModule.java

changeset 53
6a8498291606
parent 46
1574965c7dc7
child 74
91d1fc2a3a14
--- a/src/main/java/de/uapcore/lightpit/modules/ErrorModule.java	Sat May 16 15:11:07 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/modules/ErrorModule.java	Sat May 16 15:45:06 2020 +0200
@@ -32,6 +32,7 @@
 
 import javax.servlet.annotation.WebServlet;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.util.Optional;
 
 /**
@@ -49,13 +50,10 @@
 )
 public final class ErrorModule extends AbstractLightPITServlet {
 
-    public static final String REQ_ATTR_ERROR_CODE = "errorCode";
     public static final String REQ_ATTR_RETURN_LINK = "returnLink";
 
-    private ResponseType handle(HttpServletRequest req, int sc) {
-
-        req.setAttribute(REQ_ATTR_ERROR_CODE, sc);
-
+    @RequestMapping(requestPath = "generic", method = HttpMethod.GET)
+    public ResponseType onError(HttpServletRequest req, HttpServletResponse resp) {
         Optional.ofNullable(req.getHeader("Referer")).ifPresent(
                 referer -> req.setAttribute(REQ_ATTR_RETURN_LINK, referer)
         );
@@ -65,19 +63,4 @@
 
         return ResponseType.HTML;
     }
-
-    @RequestMapping(requestPath = "404.html", method = HttpMethod.GET)
-    public ResponseType handle404(HttpServletRequest req) {
-        return handle(req, 404);
-    }
-
-    @RequestMapping(requestPath = "403.html", method = HttpMethod.GET)
-    public ResponseType handle403(HttpServletRequest req) {
-        return handle(req, 403);
-    }
-
-    @RequestMapping(requestPath = "500.html", method = HttpMethod.GET)
-    public ResponseType handle500(HttpServletRequest req) {
-        return handle(req, 500);
-    }
 }

mercurial