Checking your account

You can read the lesson while its saved answers and constructions load. Learning controls will open once that work is ready.

Python Exceptions

Exception Chaining in Python

BOTIE

A low-level failure can need a higher-level explanation. An integer conversion might fail while reading an application setting, so the caller needs to know which setting failed as well as what the conversion reported. Throwing away the earlier failure makes that harder to diagnose.

PEP 3134, created in 2005 for Python 3.0, addressed lost exception information and explicit exception chaining. Python’s raise ... from ... form can attach the original exception as the cause of a new one. It lets a layer explain its own operation while preserving the failure beneath it.

Sources for this history