Closed
Description
We have 3 error pages (src/main/webapp/WEB-INF/views/error/{403,404,500}.html
) that nearly identical to each other:
--- 403.html 2019-05-07 18:43:19.988009600 +0100
+++ 500.html 2019-05-07 18:43:19.993828400 +0100
@@ -10,3 +10,3 @@
<meta name="robots" content="noindex" />
- <title th:text="#{t_403_title}">403: forbidden</title>
+ <title th:text="#{t_500_title}">500: internal server error</title>
<link rel="shortcut icon" type="image/x-icon" href="../../../favicon.ico" th:href="${FAVICON_ICO}" />
@@ -56,6 +56,6 @@
<h1 id="error-code">
- 403
+ 500
</h1>
- <h4 id="error-msg" th:text="#{t_403_description}">
- Forbidden
+ <h4 id="error-msg" th:utext="#{t_500_description('<br />')}">
+ Internal<br />server error
</h4>
The difference are the following:
- title
- error code
- error message
The task is to combine them into a single page and use condition to find out what eror message/code. Perhaps, we can utilize th:switch
/th:case
.
See also https://www.thymeleaf.org/doc/articles/springsecurity.html part 3 with an example of that approach. Keep in mind, that our approach will be similar by idea but not literally -- we won't pass error message from controller but will decided what message to show dependig on a reponse status.