[jdom-interest] JDOMException.printStackTrace()
Rosen, Alex
arosen at silverstream.com
Thu Mar 8 14:59:23 PST 2001
I believe that JDOMException.printStackTrace() should *not* print its own stack
trace - it should only print the stack trace of the root cause (when there is a
root cause). The JDOMException's stack trace is always basically a subset of
the root cause's. For example:
org.jdom.JDOMException: Error on line 0: File "Y:\web.xml" not found.
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:407)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:533)
at
com.sssw.ide.tools.depledit.FileAnalyzerXML.analyzeFile(FileAnalyzerXML.java:11
2)
[...]
Root cause: org.xml.sax.SAXParseException: File "Y:\web.xml" not found.
at
org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1014)
at
org.apache.xerces.readers.DefaultEntityHandler.startReadingFromDocument(Default
EntityHandler.java:499)
at
org.apache.xerces.framework.XMLParser.parseSomeSetup(XMLParser.java:304)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:899)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:395)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:533)
at
com.sssw.ide.tools.depledit.FileAnalyzerXML.analyzeFile(FileAnalyzerXML.java:11
2)
[...]
The only extra info that the top stack trace gives you is that the exception
was re-thrown at SAXBuilder.java:407 which isn't very useful. And printing out
both stack traces is more confusing, and creates more text to wade through when
looking for the actual cause of the problem (which is always the root cause's
stack trace, and not the wrapper's). This is how we implement our own
"wrappered" exceptions, and we haven't had a problem with it.
Does this sound like an OK idea?
Alex
More information about the jdom-interest
mailing list