The following code:
try {
value = parse(myData);
} catch (Exception e) {
if ( e instanceof IOException|| e instanceof IllegalArgumentException) {
logger.debug("illegal argument");
} else {
logger.debug("this is printing");
}
}
Parse method:
parse(String data) throws IOException, IllegalArgumentException {
// do validation
throw new IllegalArgumentException("illegal");
}
I was expecting "Illegal argument". But instead it shows "this is printing".
Did I miss anything here?