Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...