Java Throwable.getCause()
Syntax
Throwable.getCause() has the following syntax.
public Throwable getCause()
Example
In the following code shows how to use Throwable.getCause() method.
/*from w w w . j av a 2 s . c o m*/
public class Main {
public static Throwable getDeepestThrowable(Throwable t) {
Throwable parent = t;
Throwable child = t.getCause();
while (null != child) {
parent = child;
child = parent.getCause();
}
return parent;
}
}