Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (3.9k points)
I have always been of the belief that if a method can throw an exception then it is reckless not to protect this call with a meaningful try block.

SO, Why should I not wrap every block in “try”-“catch”?

1 Answer

0 votes
by (46k points)

A method should solely catch an exception if it can handle it in some practical way.

Otherwise, pass it on up, in the belief that a process higher up the call stack can get a sense of it.

 It's a healthy practice to have an unhandled exception handler (with logging) at the highest level of the call stack to assure that any fatal errors are logged.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.6k answers


108k users

Browse Categories