Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<%@ include file="/common/taglibs.jsp" %>
<%@ page import="org.slf4j.Logger, org.slf4j.LoggerFactory" %>

<title>Data Access Error</title>
<content tag="heading">Data Access Failure</content>
Expand All @@ -7,10 +8,34 @@
<c:out value="${requestScope.exception.message}"/>
</p>

<%
Exception ex = (Exception) request.getAttribute("exception");
ex.printStackTrace(new java.io.PrintWriter(out));
%>
<p>
<strong>Note:</strong> The full error details are shown below and have been logged to the server for review.
If this error persists, please contact the system administrator.
</p>

<details>
<summary>Show full error details</summary>
<pre style="white-space: pre-wrap; word-wrap: break-word; background-color: #f5f5f5; padding: 10px; border: 1px solid #ddd; overflow-x: auto;"><%
Logger logger = LoggerFactory.getLogger("org.cipres.treebase.web.errors");
Exception ex = (Exception) request.getAttribute("exception");
if (ex != null) {
// Log the exception to server logs for administrator review
logger.error("Data access failure encountered", ex);

// Print the stack trace to the page using try-with-resources
try (java.io.StringWriter sw = new java.io.StringWriter();
java.io.PrintWriter pw = new java.io.PrintWriter(sw)) {
ex.printStackTrace(pw);
pw.flush();
out.print(org.springframework.web.util.HtmlUtils.htmlEscape(sw.toString()));
} catch (java.io.IOException ioEx) {
logger.error("Error writing exception details", ioEx);
out.print("Error displaying exception details.");
}
} else {
out.print("No exception details available.");
}
%></pre>
</details>

<a href="/user/submissionList.html" onclick="history.back();return false">&#171; Back</a>
Original file line number Diff line number Diff line change
@@ -1,46 +1,60 @@
<%@ include file="/common/taglibs.jsp" %>
<%@ page import="org.slf4j.Logger, org.slf4j.LoggerFactory" %>

<title>Java Uncaught Exception</title>
<content tag="heading">Uncaught Exception Encountered</content>

<p>
An unexpected error occurred while processing your request.
</p>

<%
try {
// The Servlet spec guarantees this attribute will be available
Throwable exception = (Throwable) request.getAttribute("javax.servlet.error.exception");
<p>
<strong>Note:</strong> The full error details are shown below and have been logged to the server for review.
If this error persists, please contact the system administrator.
</p>

if (exception != null) {
if (exception instanceof ServletException) {
// It's a ServletException: we should extract the root cause
ServletException sex = (ServletException) exception;
Throwable rootCause = sex.getRootCause();
if (rootCause == null)
rootCause = sex;
out.println("** Root cause is: "+ rootCause.getMessage());
rootCause.printStackTrace(new java.io.PrintWriter(out));
}
else {
// It's not a ServletException, so we'll just show it
exception.printStackTrace(new java.io.PrintWriter(out));
}
}
else {
out.println("No error information available");
}
<details>
<summary>Show full error details</summary>
<pre style="white-space: pre-wrap; word-wrap: break-word; background-color: #f5f5f5; padding: 10px; border: 1px solid #ddd; overflow-x: auto;"><%
Logger logger = LoggerFactory.getLogger("org.cipres.treebase.web.errors");
try (java.io.StringWriter sw = new java.io.StringWriter();
java.io.PrintWriter pw = new java.io.PrintWriter(sw)) {

// The Servlet spec guarantees this attribute will be available
Throwable exception = (Throwable) request.getAttribute("javax.servlet.error.exception");

// Display cookies
out.println("\nCookies:\n");
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
out.println(cookies[i].getName() + "=[" + cookies[i].getValue() + "]");
}
}

} catch (Exception ex) {
ex.printStackTrace(new java.io.PrintWriter(out));
if (exception != null) {
Throwable rootCause = exception;
if (exception instanceof ServletException) {
// It's a ServletException: we should extract the root cause
ServletException sex = (ServletException) exception;
if (sex.getRootCause() != null) {
rootCause = sex.getRootCause();
}
}

// Log the exception to server logs
logger.error("Uncaught exception encountered", rootCause);

pw.println("** Exception: " + rootCause.getClass().getName());
pw.println("** Message: " + rootCause.getMessage());
pw.println();
pw.println("** Stack trace:");
rootCause.printStackTrace(pw);
} else {
pw.println("No error information available");
}

pw.flush();
out.print(org.springframework.web.util.HtmlUtils.htmlEscape(sw.toString()));
} catch (Exception ex) {
logger.error("Error while displaying exception page", ex);
out.print("Error displaying exception details.");
}
%>
%></pre>
</details>

<p>
<a href="/" onclick="history.back();return false">&#171; Back</a>
</p>