Error Handling¶
The exception handling in java is one of the powerful mechanism to handle the run time errors so that normal flow of the application can be maintained.
Provide Context with Exceptions¶
Create informative error messages and pass them along with your exceptions. Mention the operation that failed and the type of failure.
If you are logging in your application, pass along enough information to know the reason.
Define Exception Classes in Terms of a Caller’s Needs¶
Instead of writing more numbers of catches ,wrapping those exceptions in one exception.
Define the Normal Flow¶
First separate Business Logic and Error Handling logic. And put that error handling logic in bottom.