NIHVIVO-3088 Display generic error page rather than white screen when there's a processing error in a freemarker controller.

This commit is contained in:
ryounes 2011-08-03 15:43:20 +00:00
parent c356b16807
commit 74357c15c6

View file

@ -78,8 +78,10 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
super.doGet(request,response); super.doGet(request,response);
try {
VitroRequest vreq = new VitroRequest(request); VitroRequest vreq = new VitroRequest(request);
ResponseValues responseValues = null;
try {
Configuration config = getConfig(vreq); Configuration config = getConfig(vreq);
vreq.setAttribute("freemarkerConfig", config); vreq.setAttribute("freemarkerConfig", config);
@ -89,13 +91,26 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
return; return;
} }
ResponseValues responseValues = processRequest(vreq); responseValues = processRequest(vreq);
doResponse(vreq, response, responseValues); doResponse(vreq, response, responseValues);
} catch (TemplateProcessingException e) {
log.error(e.getMessage(), e);
} catch (Throwable e) { } catch (Throwable e) {
log.error("FreeMarkerHttpServlet could not forward to view.", e); if (e instanceof IOException || e instanceof ServletException) {
try {
throw e;
} catch (Throwable e1) {
handleException(vreq, response, e);
}
}
handleException(vreq, response, e);
}
}
protected void handleException(VitroRequest vreq, HttpServletResponse response, Throwable t) throws ServletException {
try {
doResponse(vreq, response, new ExceptionResponseValues(t));
} catch (TemplateProcessingException e) {
throw new ServletException();
} }
} }