Exception Propagation Across Function Calls

An exception that is unhandled in one call can travel to a caller able to handle it. Pending normal work along the way may be abandoned.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Trace three calls
  2. Handle it where repair is possible

Trace three calls

A report calls a row reader, which calls a count parser. If conversion raises and the reader does not handle it, the report no longer receives a normal row result from that call. Nested call traces illustrate the missing return.

Handle it where repair is possible

A command can turn the known parser error into a field diagnostic, while a library may propagate it. Use a function contract to identify which behaviors each layer promises.[1]

References

  1. Python Software Foundation, Python Tutorial: Errors and Exceptions ↩