Exception handling is a cornerstone of all robust Java applications.
It is difficult to write a simple application without catching or throwing exceptions, so every Java developer needs to understand exceptions in detail, including the following keywords and where to use them: try, catch, throw, throws, and finally.
Tip: You can't be a good Java developer without understanding how to use exceptions properly. Read the Java tutorials.
In this chapter:
[exception.why] Why exceptions?
[exception.understand] Understand Exceptions
[exception.wrap] Wrap exceptions until recognized
[exception.try] Trying too hard
[exception.when] When to use exceptions
[exception.checked] Checked Exceptions
[exception.throwable] What to use Throwable for
[exception.escape] Escaping from legacy code
[exception.error] It's ok to throw (and catch!) Error
[exception.rethrow] Why rethrow an exception?
[exception.cause] Throwable.getCause() for debugging
[exception.handle] Handle all handleable exceptions
[exception.name] Suffix exception classes with “Exception”
[exception.finally] Finally is your friend
[exception.app] Exception handling for Applications
[exception.package] Define your own package exceptions
[exception.message] What to put in exception.getMessage()
[exception.data] An Exception is not for passing data
[exception.throw] Exceptions are for throwing
[exception.generator] Write an exception generator
[exception.handler] Write an exception handler
[exception.why] Why exceptions?
[exception.understand] Understand Exceptions
[exception.wrap] Wrap exceptions until recognized
[exception.try] Trying too hard
[exception.when] When to use exceptions
[exception.checked] Checked Exceptions
[exception.throwable] What to use Throwable for
[exception.escape] Escaping from legacy code
[exception.error] It's ok to throw (and catch!) Error
[exception.rethrow] Why rethrow an exception?
[exception.cause] Throwable.getCause() for debugging
[exception.handle] Handle all handleable exceptions
[exception.name] Suffix exception classes with “Exception”
[exception.finally] Finally is your friend
[exception.app] Exception handling for Applications
[exception.package] Define your own package exceptions
[exception.message] What to put in exception.getMessage()
[exception.data] An Exception is not for passing data
[exception.throw] Exceptions are for throwing
[exception.generator] Write an exception generator
[exception.handler] Write an exception handler