0 votes
1 view
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 (46.1k 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.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...