The worst catch in history
Block: Comment
If you want to catch
Block to keep the program running. If an exception is thrown, you capture it, and do not close the program or give an error message, but continue running. But sometimes, there is no such good thing.
Let's take a look at the Division operator below. It looks interesting. What's the matter?
You should handle exceptions instead of hiding them.
You can let the program continue to run does not mean that you have handled the exception. In the above Code, divide
() Method does not cause program crash. But what if other methods call this method and try to print the result? If the divisor is zero, this method may return an incorrect and unexpected value.
You should handle exceptions instead of adding comments and hiding them. If you cannot handle the exception, do not leave an empty or annotated catch.
Block! This makes it harder for others to find errors. It makes it easier for programs to throw exceptions because it is easy to find out the problem.