13. Exception Handling
In this chapter you’ll learn:
• How exception and error handling works.
• To use
catch to detect, indicate and handle exceptions, respectively.
• To use the
finally block to release resources.
• How stack unwinding enables exceptions not caught in one scope to be caught in another scope.
• How stack traces help in debugging.
• How exceptions are arranged in an exception-class hierarchy.
• To declare new exception classes.
• To create chained exceptions that maintain complete stack-trace information.
It is common sense to take a method and try it. If it fails, admit it frankly and try another. But above all, try something.
—Franklin Delano Roosevelt
O! throw away the worser part of it, And live ...