2.8 Leveraging exception matching rules
The try statement lets us capture an exception. When an exception is raised, we have a number of choices for handling it:
Ignore it: If we do nothing, the program stops. We can do this in two ways—don’t use a try statement in the first place, or don’t have a matching except clause in the try statement.
Log it: We can write a message and use a raise statement to let the exception propagate after writing to a log. The expectation is that this will stop the program.
Recover from it: We can write an except clause to do some recovery action to undo any effects of the partially completed try clause.
Silence it: If we do nothing (that is, use the pass statement), then processing is resumed after the try statement. This silences the exception, but does not correct the underlying problem, or supply alternative results as a recovery attempt.
Rewrite it: We can raise a different...