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:
parent
c356b16807
commit
74357c15c6
1 changed files with 22 additions and 7 deletions
|
@ -78,8 +78,10 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
|||
|
||||
super.doGet(request,response);
|
||||
|
||||
try {
|
||||
VitroRequest vreq = new VitroRequest(request);
|
||||
ResponseValues responseValues = null;
|
||||
|
||||
try {
|
||||
|
||||
Configuration config = getConfig(vreq);
|
||||
vreq.setAttribute("freemarkerConfig", config);
|
||||
|
@ -89,13 +91,26 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
|||
return;
|
||||
}
|
||||
|
||||
ResponseValues responseValues = processRequest(vreq);
|
||||
responseValues = processRequest(vreq);
|
||||
doResponse(vreq, response, responseValues);
|
||||
|
||||
} catch (TemplateProcessingException e) {
|
||||
log.error(e.getMessage(), 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue