http://tutorials.jenkov.com/java-exception-handling/index.html
一个好的java网站
http://www.java-tips.org/java-se-tips/java.util.logging/how-to-log-an-exception.html
Exception handling is a very important yet often neglected aspect of writing robust software. When an error occurs in a Java program it usually results in an exception being thrown. How you throw, catch and handle these exception matters. There are several different ways to do so. Not all are equally efficient and fail safe.
This trail digs deeper into exception handling in Java. The trail covers various do's and dont's of Java exception handling. It also covers a few techniques for efficient and less error prone exception handling. Hopefully you can benefit from some of these texts.
Below follows a quick introduction to what you can learn in this Java exception handling trail.
Basic Java Exception Handling
The first 2 texts on Java exception handling covers the basics of Java's exception throwing and catching mechanism, and exception hierarchies. These texts are:
Checked vs. Unchecked Exceptions in Java
Java is one of the few languages to support both checked and unchecked exceptions. In the text Checked or Unchecked Exceptions? I discuss the difference between these two types of exceptions. I also end up recommending unchecked exceptions over checked exceptions.
General Java Exception Handling Advice
The middle 6 texts in this Java exception handling trail covers issues like "fail safe exception" handling, "where to log exceptions", advice on throwing exceptions during validation etc. In other words, various advice on what to remember when designing your application exception throwing and handling.
Advanced Exception Handling in Java
The two texts Exception Handling Templates and Exception Enrichment discusses two somewhat more advanced exception handling techniques that can clean up your code a bit. Exception templates moves all the "try-catch" code to one or more reusable exception handling templates. Exception enrichment rids you of having tons of different exceptions in your exception hierarchy. It also helps you avoid long exception stack traces, and get truly unique error codes for each error in your application.
Most Popular on Java Exception Handling
The most popular texts in this Java exception handling tutorial are the texts on Exception Handling Templates and Exception Enrichment.
Table of Contents for Java Exception Handling Tutorial
Below is a list of the texts this trail Java Exception Handling contains. The list is repeated at the top right of every page in the trail.