I think you're right. Looks like we need to make a few improvements:
1) getStackTrace: Should this handle nested?
public static String getStackTrace(Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
Throwable ts = getThrowables(t);
for(int i=0; i<ts.length; i++) {
ts[i].printStackTrace(pw);
if(isCauseMethod(ts[i])) {
break;
}
}
return sw.getBuffer().toString()
}
static public boolean isCauseMethod(Throwable t) {
// checks if this is a 'nested' exception. if so we trust it
// to print itself and its children (?)
}
2)
public void printStackTrace(Throwable t, PrintStream) [calls
getStackTrace]
public void printStackTrace(Throwable, PrintWriter)
Any views?
On Wed, 22 Jan 2003, Gary Gregory wrote:
> Hm, I do not see ExceptionUtils.toString(Throwable) in Commons-Lang v.1.0.1
> or in CVS (as of v.1.20, the latest as far as I can tell). To be more
> specific, what I really want to is something that will work with a
> NestableException or a JRE 1.4 Exception.
>
> Gary
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 22, 2003 10:00 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Exception to XML?
>
>
> ExceptionUtils.toString(Throwable) IIRC.
> Stephen
>
> > from: Gary Gregory <[EMAIL PROTECTED]>
> > date: Wed, 22 Jan 2003 17:11:39
> > to: [EMAIL PROTECTED]
> > subject: Re: Exception to XML?
> >
> > Hello All,
> >
> > Is there something somewhere in the Commons or XML project that will let
> me
> > turn an Exception in XML (DOM or String)? I would then use this XML
> snippet
> > as part of a larger enclosing document.
> >
> > Thank you,
> > Gary
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>