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
I'll echo "catch the most specific exception you can".
I routinely catch IOException and display some sort of "error reading file" message, then allow the user to select another file or whatever is appropriate. If the file is really bad, there's probably not much the user can do about it, but at least you can let them know the file is bad.
If you get a FileNotFoundException the real problem is almost surely that the user seleected the wrong file name or a hard-coded file name is no longer valid. I routinely display messages for that.
I almost never catch "Exception". What are you going to do about it? There's pretty much nothing you can do to recover from "something went wrong but no further details are available". In some contexts I suppose you could at least display an error message rather than just dying, but that's about it.