Living with unhandled exceptions
An exception can occur in two conceptual situations. The first is when the caller expects it to happen, as we did when building minspect._is_pymel
in Chapter 1, Introspecting Maya, Python, and PyMEL. An AttributeError
being raised indicated to our algorithm that we should try a different attribute. Exceptions were being used for flow control and had no ill effects.
The second situation, which is the focus of this and the following section, is when the caller does not expect an exception. In this case, the exception bubbles up to a higher layer. If the exception bubbles all the way up to the Python interpreter (the exception is not caught by any except
clause), it is called an unhandled exception. When an unhandled exception occurs, the Python process exits or some default error handler is invoked, often printing the exception information.
Failing in this catastrophic way when an unhandled exception occurs is called failing fast, and it is generally a good...