Catching an exception that is nested into another exception
- by Bernhard V
Hi,
I want to catch an exception, that is nested into another exception.
I'm doing it currently this way:
} catch (RemoteAccessException e) {
if (e != null && e.getCause() != null && e.getCause().getCause() != null) {
MyException etrp = (MyException) e.getCause().getCause();
...
} else {
throw new IllegalStateException("Error at calling service 'beitragskontonrVerwalten'");
}
}
Is there a way to do this more efficient and elegant?