| 1 | raise | stops the line and starts the climb | the frame that finds the problem | nothing; it hands the problem to the caller | a wrong value returned instead, failing far from its cause |
|---|
| 2 | the exception object | carries the error’s type and message up the stack | created by raise | its class decides which handlers can catch it | a message with no detail, such as a bare ValueError() |
|---|
| 3 | the climb | ends each frame early until a handler matches | every frame between the raise and the handler | which lines never run | work half done: a loop stopped at record 118 |
|---|
| 4 | the default handler | prints the traceback and exits with status 1 | the interpreter, above main() | nothing; it runs when no handler matched | a traceback in a cron mail and status 1 for every failure |
|---|
| 5 | the traceback | records every frame the error left, oldest call first | on the exception, printed on stderr | nothing; it is the record you read | the line where the error surfaced, which may not be the mistake |
|---|
| 6 | try and except | catches a matching error so the frame can carry on | the frame that can act on the error | the first clause whose class matches runs | a job that reports success with every record skipped |
|---|
| 7 | the class hierarchy | groups errors so one clause catches a whole family | every except clause | a clause catches its own class and every subclass | Ctrl-C ignored, because a bare except: caught it |
|---|
| 8 | finally and with | release resources and finish transactions on every way out | the frame that acquired the resource | nothing; the cleanup runs whatever happened | connections left open and half-written data after a failure |
|---|
| 9 | your exception classes | name failures by what the caller should do next | errors.py, raised by your own code | which handler, and so which action, applies | callers comparing message strings to tell errors apart |
|---|
| 10 | raise … from | turns a library’s error into yours and keeps the original | where your code calls a library | nothing; it links the original as the cause | a log line with your message and none of urllib’s details |
|---|
| 11 | cause, context and notes | keep the original error and extra facts on the exception | the exception object | nothing; they add what the traceback prints | “During handling…” where you meant a deliberate translation |
|---|
| 12 | the boundary handler | catches every error left, once, at the top | main(), or the top of each request or job | how each kind of failure is reported | the same traceback logged three times, or not at all |
|---|
| 13 | the log file | keeps the traceback for whoever investigates | outside the process | nothing; it is what you read the next morning | a message with no traceback, from log.error without exc_info |
|---|
| 14 | the exit status | tells the scheduler which kind of failure happened | the process, read by cron or CI | whether a monitor pages someone or waits | status 1 for a partner outage, paging someone for nothing |
|---|
| 15 | retry with backoff | repeats a call whose error goes away on its own | the one call to the partner APIs | which errors get another attempt, and when | dozens of requests to a partner that is down, or a job that never ends |
|---|
| 16 | ExceptionGroup | carries several failures as one exception | the frame that runs independent units of work | nothing; it reports every failure together | a report naming one partner while the next failure goes unseen |
|---|
| 17 | except* | handles each kind of failure inside a group | the boundary | every clause with matching members runs once | one handler for the whole group that can’t act on each kind |
|---|
| · | the job’s functions | the frames an error climbs through | the process | nothing about errors, unless they hold a handler | a handler in the wrong frame: too low to act, or too high to know |
|---|