Improved getTargetException using while loop.

This commit is contained in:
Erwin Vervaet
2007-04-09 07:49:49 +00:00
parent 415dd8c58c
commit 4d3f5eb9c6
2 changed files with 61 additions and 5 deletions

View File

@@ -69,11 +69,10 @@ public class MethodInvocationException extends NestedRuntimeException {
* @return the target throwable
*/
public Throwable getTargetException() {
if (getCause() instanceof InvocationTargetException) {
return ((InvocationTargetException)getCause()).getTargetException();
}
else {
return getCause();
Throwable targetException = getCause();
while (targetException instanceof InvocationTargetException) {
targetException = ((InvocationTargetException)targetException).getTargetException();
}
return targetException;
}
}