Methods Summary |
---|
public static java.lang.Throwable[] | getCauses(java.lang.Throwable start)Get the chain of exceptions via getCause(). The first element is the
Exception passed.
final ArrayList<Throwable> list = new ArrayList<Throwable>();
boolean haveNonException = false;
Throwable t = start;
while ( t != null )
{
list.add( t );
if ( ! ( t instanceof Exception ) )
{
haveNonException = true;
}
final Throwable temp = t.getCause();
if ( temp == null )
break;
t = temp;
}
final Throwable[] results = haveNonException ?
new Throwable[ list.size() ] : new Exception[ list.size() ];
list.toArray( results );
return( results );
|
public static java.lang.Throwable | getRootCause(java.lang.Throwable e)Get the original troublemaker.
final Throwable[] causes = getCauses( e );
return( causes[ causes.length - 1 ] );
|
public static java.lang.String | getStackTrace()
return toString(new Exception("STACK TRACE"));
|
public static java.lang.String | getStackTrace(java.lang.Throwable t)Get the stack trace as a String.
final StringBuffer buf = new StringBuffer();
final StackTraceElement[] elems = t.getStackTrace();
for( int i = 0; i < elems.length; ++i )
{
buf.append( elems[ i ] );
buf.append( "\n" );
}
return( buf.toString() );
|
public static java.lang.String | toString(java.lang.Throwable t)
final String SEP = System.getProperty( "line.separator" );
final Throwable rootCause = getRootCause( t );
return rootCause.getClass().getName() + ": " +
StringUtil.quote( rootCause.getMessage() ) + SEP +
getStackTrace( rootCause );
|