@@ -125,7 +125,8 @@ class UrlMappingsHandlerMapping extends AbstractHandlerMapping {
125125 protected Object getHandlerInternal (HttpServletRequest request ) throws Exception {
126126
127127 def matchedInfo = request. getAttribute(MATCHED_REQUEST )
128- if (matchedInfo != null ) return matchedInfo
128+ def errorStatus = request. getAttribute(WebUtils . ERROR_STATUS_CODE_ATTRIBUTE )
129+ if (matchedInfo != null && errorStatus == null ) return matchedInfo
129130
130131 String uri = urlHelper. getPathWithinApplication(request);
131132 def webRequest = GrailsWebRequest . lookup(request)
@@ -134,22 +135,26 @@ class UrlMappingsHandlerMapping extends AbstractHandlerMapping {
134135
135136 String version = findRequestedVersion(webRequest)
136137
137- def errorStatus = request . getAttribute( WebUtils . ERROR_STATUS_CODE_ATTRIBUTE )
138+
138139 if (errorStatus) {
139140 def exception = request. getAttribute(WebUtils . ERROR_EXCEPTION_ATTRIBUTE )
141+ UrlMappingInfo info
140142 if (exception instanceof Throwable ) {
141143 exception = ExceptionUtils . getRootCause(exception)
142144 def exceptionSpecificMatch = urlMappingsHolder. matchStatusCode(errorStatus. toString(). toInteger(), (Throwable ) exception)
143145 if (exceptionSpecificMatch) {
144- return exceptionSpecificMatch
146+ info = exceptionSpecificMatch
145147 }
146148 else {
147- return urlMappingsHolder. matchStatusCode(errorStatus. toString(). toInteger())
149+ info = urlMappingsHolder. matchStatusCode(errorStatus. toString(). toInteger())
148150 }
149151 }
150152 else {
151- return urlMappingsHolder. matchStatusCode(errorStatus. toString(). toInteger())
153+ info = urlMappingsHolder. matchStatusCode(errorStatus. toString(). toInteger())
152154 }
155+
156+ request. setAttribute(MATCHED_REQUEST , info)
157+ return info
153158 }
154159 else {
155160
0 commit comments