10

5 Great Resources for Exception Handling Best Practices in Java · GitHub

 2 years ago
source link: https://gist.github.com/raineorshine/5521119
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

General Tip

"The trick is to catch exceptions at the proper layer, where your program can either meaningfully recover from the exception and continue without causing further errors, or provide the user with specific information, including instructions on how to recover from the error. When it is not practical for a method to do either of these, simply let the exception go so it can be caught later on and handled at the appropriate level."

Resources

Advantages of Exceptions
Excellent example of separating error-handling code from program logic

Three Rules for Effective Exception Handling
Longer explanation and case study of exception use, including the basic principles of "throw early" and "catch late". Clear and thorough.

Java Tutorials: Exceptions
A well-organized series of tutorials about what exceptions are and how to use them.

Exception Handling Antipatterns
Some precise examples of incorrect usage of exceptions.

Best Practices for Exception Management
Most of the above resources for found in this excellent Stack Overflow question.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK