A practical look at Java exceptions
An excellent three-part
series on
working with Java exceptions was recently published by
JavaWorld.
Among other things, it explains how to use exceptions correctly and effectively in your programs.
It also describes the useful technique of exception chaining,
which means wrapping one exception in another. This is useful when designing an object's interface.
You can wrap a more specific exception in a more general one, which is especially handy
when extending the behavior of the method that throws it.
The author also covers the important work of localizing exceptions. Overall, the series looks
at exceptions from three perspectives.
The author of the code
The exception that was thrown and its output should help you identify what caused it.
The programmer using the code
A declared exception can be handled or passed up the call stack.
The user
If an error raises an exception, the user should get a message they can understand instead of one that just says java.lang.Exception
Related articles
Related CZ Podcast episodes
- #3 · Java 6 SE, Vývoj webových aplikací
Dagi and Filemon discuss Java 6 and web application frameworks. · Czech audio
- #1 · Vývojová prostředí v Javě
The first CZ Podcast episode looks at Java development environments. · Czech audio