diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerConfigurationLoader.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerConfigurationLoader.java index 39c328e8e..47198deb4 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerConfigurationLoader.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerConfigurationLoader.java @@ -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) { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java index 4cf87cd1a..b4eec23e0 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java @@ -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(); } } diff --git a/webapp/web/templates/freemarker/body/error/error-display.ftl b/webapp/web/templates/freemarker/body/error/error-display.ftl index 6bece3ccf..4ab973782 100644 --- a/webapp/web/templates/freemarker/body/error/error-display.ftl +++ b/webapp/web/templates/freemarker/body/error/error-display.ftl @@ -14,12 +14,16 @@
Error message: ${adminErrorData.errorMessage}
#if> <#if adminErrorData.stackTrace?has_content> -Stack trace (full trace available in the vivo log):
- ${adminErrorData.stackTrace} -+ Stack trace (full trace available in the vivo log): ${adminErrorData.stackTrace} +
+ + <#if adminErrorData.cause?has_content> +Caused by: ${adminErrorData.cause}
+ #if> + #if> + <#elseif ! errorOnHomePage> <#-- view for other users --> -Return to the home page.
+Return to the home page
#if> diff --git a/webapp/web/templates/freemarker/body/error/error-email.ftl b/webapp/web/templates/freemarker/body/error/error-email.ftl index f5265280c..f31b0c20d 100644 --- a/webapp/web/templates/freemarker/body/error/error-email.ftl +++ b/webapp/web/templates/freemarker/body/error/error-email.ftl @@ -17,18 +17,20 @@- Requested url: ${requestedUrl}. + Requested url: ${requestedUrl}
- Error message: ${errorMessage}. + Error message: ${errorMessage}
- Stack trace (full trace available in the vivo log): + Stack trace (full trace available in the vivo log): ${stackTrace}
-Caused by: ${cause}
+ #if>