Improved getTargetException using while loop.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user