What I Hate About Your Programming Language
Subject:   Java: Catch all exceptions?
Date:   2003-05-13 17:50:15
From:   anonymous2
Response to: Java: Catch all exceptions?

You should use exception handling to indicate errors.

RuntimeExceptions indicate errors in your program logic that you should fix (things like NullPointerExceptions). RuntimeExceptions are things that should NEVER happen in properly debugged code.

Checked exceptions, things like FileNotFoundException are things that can reasonably happen in code AND you cannot defend against in your code (like you can a NullPointer). Checked exceptions do not indicate logic errors in your code.

If the compiler did not force you to deal with checked exceptions then you would have to know what each method throws. To do this you would presumably need to check the documentation.

If you are going to write "proper" robust code you are going to want to handle all errors (right?). WOuld you rather have the compiler help you out or would you rahter do things manually?

One way or antoerh you should be handling all the errors - why not let the compiler help?