*
* @author Various
* @version $Version$
- *
*/
-
-
public class ServletException extends Exception {
- private Throwable rootCause;
-
-
-
-
-
/**
* Constructs a new servlet exception.
- *
*/
-
public ServletException() {
- super();
+ super();
}
-
-
-
-
/**
* Constructs a new servlet exception with the
* @param message a <code>String</code>
* specifying the text of
* the exception message
- *
*/
-
public ServletException(String message) {
- super(message);
+ super(message);
}
-
-
-
-
/**
* Constructs a new servlet exception when the servlet
* about the "root cause" exception that interfered with its
* normal operation, including a description message.
*
- *
* @param message a <code>String</code> containing
* the text of the exception message
*
* that interfered with the servlet's
* normal operation, making this servlet
* exception necessary
- *
*/
-
public ServletException(String message, Throwable rootCause) {
- super(message);
- this.rootCause = rootCause;
+ super(message, rootCause);
}
-
-
-
-
/**
* Constructs a new servlet exception when the servlet
* needs to throw an exception and include a message
* that interfered with the servlet's
* normal operation, making the servlet exception
* necessary
- *
*/
-
public ServletException(Throwable rootCause) {
- super(rootCause.getLocalizedMessage());
- this.rootCause = rootCause;
+ this(rootCause.getLocalizedMessage(), rootCause);
}
-
-
-
-
-
+
/**
* Returns the exception that caused this servlet exception.
*
- *
* @return the <code>Throwable</code>
* that caused this servlet exception
- *
*/
-
public Throwable getRootCause() {
- return rootCause;
+ return getCause();
}
}
-
-
-
-
-
Throwable rootCause = e;
Throwable rootCauseCheck = null;
// Extra aggressive rootCause finding
+ int loops = 0;
do {
- try {
- rootCauseCheck = (Throwable)IntrospectionUtils.getProperty
- (rootCause, "rootCause");
- if (rootCauseCheck!=null)
- rootCause = rootCauseCheck;
-
- } catch (ClassCastException ex) {
- rootCauseCheck = null;
- }
- } while (rootCauseCheck != null);
+ loops++;
+ rootCauseCheck = rootCause.getCause();
+ if (rootCauseCheck != null)
+ rootCause = rootCauseCheck;
+ } while (rootCauseCheck != null && (loops < 20));
return rootCause;
}
sb.append(RequestUtil.filter(stackTrace));
sb.append("</pre></p>");
- while (rootCause != null) {
+ int loops = 0;
+ while (rootCause != null && (loops < 10)) {
stackTrace = getPartialServletStackTrace(rootCause);
sb.append("<p><b>");
sb.append(sm.getString("errorReportValve.rootCause"));
sb.append(RequestUtil.filter(stackTrace));
sb.append("</pre></p>");
// In case root cause is somehow heavily nested
- try {
- rootCause = (Throwable)IntrospectionUtils.getProperty
- (rootCause, "rootCause");
- } catch (ClassCastException e) {
- rootCause = null;
- }
+ rootCause = rootCause.getCause();
+ loops++;
}
sb.append("<p><b>");