cziegeler 01/08/17 06:20:14
Modified: src/org/apache/cocoon Notification.java
Log:
Improved exception tracing
Revision Changes Path
1.3 +26 -19 xml-cocoon2/src/org/apache/cocoon/Notification.java
Index: Notification.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Notification.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Notification.java 2001/05/31 17:37:32 1.2
+++ Notification.java 2001/08/17 13:20:14 1.3
@@ -11,7 +11,7 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
-import org.apache.avalon.framework.CascadingException;
+import org.apache.avalon.framework.CascadingThrowable;
import org.xml.sax.SAXException;
@@ -95,30 +95,37 @@
setDescription(t.toString());
extraDescriptions.put("exception", t.toString());
+ // get the stacktrace: if the exception is a SAXException,
+ // the stacktrace of the embedded exception is used as the
+ // SAXException does not append it automatically
+ Throwable stackTraceException;
+ if (t instanceof SAXException
+ && ((SAXException)t).getException() != null) {
+ stackTraceException = ((SAXException)t).getException();
+ } else {
+ stackTraceException = t;
+ }
StringWriter stackTrace = new StringWriter();
- t.printStackTrace(new PrintWriter(stackTrace));
+ stackTraceException.printStackTrace(new PrintWriter(stackTrace));
extraDescriptions.put("stacktrace", stackTrace.toString());
- if(t instanceof CascadingException) {
- Throwable cause = ((CascadingException)t).getCause();
- if(cause != null) {
- extraDescriptions.put("embedded exception", cause.toString());
- stackTrace = new StringWriter();
- cause.printStackTrace(new PrintWriter(stackTrace));
- extraDescriptions.put("embedded exception stacktrace",
stackTrace.toString());
+ // if the throwable is a CascadingThrowable the strack trace
+ // is automatically appended by the CascadingThrowable, so we
+ // only have to deal with the case if the embedded exception
+ // of the CascadingThrowable is a SAXException.
+ if (t instanceof CascadingThrowable) {
+ Throwable cause = ((CascadingThrowable)t).getCause();
+ if(cause != null && cause instanceof SAXException) {
+ cause = ((SAXException)cause).getException();
+ if(cause != null) {
+ extraDescriptions.put("original exception",
cause.toString());
+ stackTrace = new StringWriter();
+ cause.printStackTrace(new PrintWriter(stackTrace));
+ extraDescriptions.put("original exception stacktrace",
stackTrace.toString());
+ }
}
}
}
- }
-
- /**
- * Constructor for the Notification object
- *
- *@param t Description of Parameter
- */
- public Notification(Object sender, SAXException se) {
- this(sender, (Throwable) se);
- addExtraDescription("SAX-processing-exception",
se.getException().toString());
}
/**
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]