NIHVIVO-3118 Add cause to error display on page and in email. Minor reformatting in error templates.

This commit is contained in:
ryounes 2011-08-12 19:12:34 +00:00
parent d2b3213c7b
commit fd585b15f3
4 changed files with 44 additions and 23 deletions

View file

@ -48,20 +48,19 @@ public class FreemarkerConfigurationLoader {
}
protected String getThemeDir(ApplicationBean appBean) {
String themeDir = null;
if (appBean == null) {
log.error("Cannot get themeDir from null application bean");
return null;
} else {
themeDir = appBean.getThemeDir();
if (themeDir == null) {
log.error("themeDir is null");
return null;
}
}
}
String themeDir = appBean.getThemeDir();
if (themeDir == null) {
log.error("themeDir is null");
return null;
}
return themeDir.replaceAll("/$", "");
}
protected FreemarkerConfiguration getConfigForTheme(String themeDir, VitroRequest vreq) {

View file

@ -146,6 +146,18 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
String stackTrace = sw.toString();
adminErrorData.put("stackTrace", stackTrace);
sw = new StringWriter();
Throwable c = t.getCause();
String cause;
if (c != null) {
c.printStackTrace(new PrintWriter(sw));
cause = sw.toString();
} else {
cause = "";
}
adminErrorData.put("cause", cause);
adminErrorData.put("datetime", new Date());
templateMap.put("errorOnHomePage", this instanceof HomePageController);
@ -174,6 +186,8 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
doResponse(vreq, response, rv);
} catch (TemplateProcessingException e) {
// We'll get here if the error was in one of the page templates; then attempting
// to display the error page also generates an error.
throw new ServletException();
}
}