Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it good to catch a more general type of Exception?

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 them) say

FileNotFoundException
ZipException

should we always trail it off and cover all bases with a

catch(IOException e){
    e.printStackTrace();
}

and then possibly go even further and catch Exception e, or is this a complete waste of time?

like image 763
user108110 Avatar asked May 21 '09 19:05

user108110


1 Answers

Generally, you only want to catch and handle exceptions you can do something with at a low level. Then at a higher level, catch any unhandled exceptions system wide, so you can record errors that occurred.

like image 188
Shane Fulmer Avatar answered Oct 11 '22 08:10

Shane Fulmer