A good java site
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:
- Basic Try Catch Finally
- Exception Hierarchies
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.
<! - <td Colspan="2"> <img src="/images/toc.png" alt="Table of Contents" /> </ td> ->
|Java Exception Handling|
|Introduction to Java Exception Handling|
|Basic Try Catch Finally|
|Checked or Unchecked Exceptions?|
|Fail Safe Exception Handling|
|Pluggable Exception Handlers|
|Logging: Where to Log Exceptions?|
|Validation: Throw Exceptions Early|
|Validation: Throw Exception or Return False?|
|Exception Handling Templates|