If we are to catch specific forms of IOException, or any other kind as a
matter of fact, and we only try and catch a couple (and define definitive outputs for t
Blankly catching any kind of exception is not a good idea. Yes, as a parent exception, it seems to provide a layer of "protection", but this is bad for a few reasons:
IOExceptions are checked. If there's nowhere in the code that's throwing it adding an unneeded catch just obscures things, and will likely confuse anyone looking at the code later.
More importantly, you don't catch exceptions to just make them go away. If they did, you could just wrap all your methods in (catch(Exception e){..}) and be done with it. Your exception catching code should be the place where you decide what to do if those errors happen, e.g.
catch(FileNotFoundException e)
{
log.error("where's the file?");return null;
}
catch(ZipException e)
{
log.error("corrupt");return null;
}
The point is to make the method well behaved under all possible conditions. The caller then deals with, for example, either file content or no content, without worrying about how the content got there.