Improved
error recovery
is one of the most powerful ways that you can increase the robustness of your
code. Error recovery is a fundamental concern for every program you write, and
it’s especially important in Java, in which one of the primary goals is
to create program components for others to use. To create a robust system, each
component must be robust.
The
goals for exception handling in Java are to simplify the creation of large,
reliable programs using less code than currently possible, with more confidence
that your application doesn’t have an unhandled error.
Exceptions
are not terribly difficult to learn, and are one of those features that provide
immediate and significant benefits to your project. Fortunately, Java enforces
all aspects of exceptions so it’s guaranteed that they will be used
consistently by both library designer and client programmer.