Catching an exception that is nested into another exception
Posted
by Bernhard V
on Stack Overflow
See other posts from Stack Overflow
or by Bernhard V
Published on 2010-06-02T06:26:43Z
Indexed on
2010/06/02
6:33 UTC
Read the original article
Hit count: 242
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?
© Stack Overflow or respective owner