Skip to content

Commit a429203

Browse files
committed
updated error page, closes mitreid-connect#858
1 parent 0360d35 commit a429203

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

openid-connect-server-webapp/src/main/webapp/WEB-INF/views/error.jsp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22
<%@ taglib prefix="o" tagdir="/WEB-INF/tags"%>
33
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
44
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"%>
5+
<%@page import="org.springframework.security.oauth2.common.exceptions.OAuth2Exception"%>
6+
<%
57
8+
if (request.getAttribute("error") != null && request.getAttribute("error") instanceof OAuth2Exception) {
9+
request.setAttribute("errorCode", ((OAuth2Exception)request.getAttribute("error")).getOAuth2ErrorCode());
10+
request.setAttribute("message", ((OAuth2Exception)request.getAttribute("error")).getMessage());
11+
} else if (request.getAttribute("javax.servlet.error.exception") != null) {
12+
Throwable t = (Throwable)request.getAttribute("javax.servlet.error.exception");
13+
request.setAttribute("errorCode", t.getClass().getSimpleName() + " (" + request.getAttribute("javax.servlet.error.status_code") + ")");
14+
request.setAttribute("message", t.getMessage());
15+
} else {
16+
request.setAttribute("errorCode", "Server error");
17+
request.setAttribute("message", "See the logs for details");
18+
}
19+
20+
%>
621
<spring:message code="error.title" var="title"/>
722
<o:header title="${title}" />
823
<o:topbar pageName="Error" />
@@ -11,11 +26,11 @@
1126
<div class="offset1 span10">
1227
<div class="hero-unit">
1328
<h1><span><spring:message code="error.header"/></span>
14-
<span class="text-error"><c:out value="${error.getOAuth2ErrorCode()}" /></span>
29+
<span class="text-error"><c:out value="${ errorCode }" /></span>
1530
</h1>
1631
<p>
1732
<spring:message code="error.message"/>
18-
<blockquote class="text-error"><b><c:out value="${error.message}" /></b></blockquote>
33+
<blockquote class="text-error"><b><c:out value="${ message }" /></b></blockquote>
1934
</p>
2035

2136
</div>

openid-connect-server-webapp/src/main/webapp/WEB-INF/web.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,9 @@
6767
<trim-directive-whitespaces>true</trim-directive-whitespaces>
6868
</jsp-property-group>
6969
</jsp-config>
70-
70+
71+
<error-page>
72+
<location>/error</location>
73+
</error-page>
74+
7175
</web-app>

0 commit comments

Comments
 (0)