This section addresses general guidelines for working with exceptions. It is intended to provide examples of how to use exception handling in a more useful and productive manner. While poor techniques may not result in a compile-time error, or an incorrect program, they often reflect a poor design.
When an exception is thrown and then caught we will sometimes want to try and re-execute the offending code. This is not difficult if the code is structured properly.
In this code sequence, errors are assumed to be present when the
try block is entered. If an error is generated it is caught and handled by the
catch block. As the
errorsArePresent is still set to true, the try block will ...