request.setAttribute("exception", new GrailsWrappedRuntimeException(getServletContext(), t));
}
}
final UrlMappingsHolder urlMappingsHolder = (UrlMappingsHolder)getBean(UrlMappingsHolder.BEAN_ID);
UrlMappingInfo urlMappingInfo = null;
if (t != null) {
// stackFilterer.filter(t, true);
urlMappingInfo = urlMappingsHolder.matchStatusCode(statusCode, t);
if (urlMappingInfo == null) {
urlMappingInfo = urlMappingsHolder.matchStatusCode(statusCode, GrailsExceptionResolver.getRootCause(t));
}
}
if (urlMappingInfo == null) {
urlMappingInfo = urlMappingsHolder.matchStatusCode(statusCode);
}
if (urlMappingInfo == null) {
renderDefaultResponse(response, statusCode);
return;
}
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
boolean restoreOriginalRequestAttributes = false;
final GrailsWebRequest webRequest;
if (requestAttributes instanceof GrailsWebRequest) {
webRequest = (GrailsWebRequest) requestAttributes;
urlMappingInfo.configure(webRequest);
}
else {
restoreOriginalRequestAttributes = true;
webRequest = new GrailsWebRequest(request, response, getServletContext());
RequestContextHolder.setRequestAttributes(webRequest);
urlMappingInfo.configure(webRequest);
}
// don't reuse cached controller attribute
webRequest.removeAttribute(GrailsApplicationAttributes.GRAILS_CONTROLLER_CLASS_AVAILABLE, WebRequest.SCOPE_REQUEST);
HttpServletResponse originalResponse = WrappedResponseHolder.getWrappedResponse();
try {
WrappedResponseHolder.setWrappedResponse(response);
String viewName = urlMappingInfo.getViewName();
if (viewName == null || viewName.endsWith(GSP_SUFFIX) || viewName.endsWith(JSP_SUFFIX)) {
// GrailsClass controller = UrlMappingUtils.passControllerForUrlMappingInfoInRequest(webRequest, urlMappingInfo,
// webRequest.getApplicationContext().getBean(UrlConverter.BEAN_NAME, UrlConverter.class),
// webRequest.getAttributes().getGrailsApplication());
// if(controller != null) {