I have the following:
public void method(){
try {
methodThrowingIllegalArgumentException();
return;
} catch (IllegalArgumentException e) {
anotherMethodThrowingIllegalArgumentException();
return;
} catch (IllegalArgumentException eee){ //1
//do some
return;
} catch (SomeAnotherException ee) {
return;
}
}
Java does not allow us to catch the exception twice, so we got compile-rime error at //1
. But I need to do exactly what I try to do:
try the methodThrowingIllegalArgumentException()
method first and if it fails with IAE
, try anotherMethodThrowingIllegalArgumentException();
, if it fails with IAE
too, do some and return. If it fails with SomeAnotherException
just return.
How can I do that?