The try block contains protected code that may throw an exception. The block is executed until an exception is thrown or it is successfully completed.
You can take a look at How often should I use try and catch
The basic rule for catching exceptions is to catch exceptions if and only if you have a meaningful way to handle them.
Do not catch the exception if you are going to throw an exception and throw it on the stack. It does not contain any meaning and does not put code.
Catch an exception if you expect a failure in a certain part of your code, and if you have a reserve for it.
Of course, you always deal with checked exceptions that require the use of try / catch blocks, in which case you have no other choice. Even with a proven exception, make sure that you record and process correctly as clean as possible.
Mohit shrivastava
source share