Affiliate disclosure
Book titles on this page link to Amazon. As an Amazon Associate, DataField.Dev earns from qualifying purchases — at no additional cost to you.
Further Reading: Error Handling
Python Exception System
-
Python Documentation: "Errors and Exceptions" Tutorial. (Tier 1) The official Python tutorial chapter on exceptions. Clear, well-written, and authoritative. Covers everything in this chapter and more, including exception chaining (
raise ... from ...) and the full exception hierarchy. Available at docs.python.org/3/tutorial/errors.html. -
Python Documentation: "Built-in Exceptions." (Tier 1) The complete list of Python's built-in exception types with their inheritance hierarchy. Essential reference when deciding which exception type to raise or catch. Available at docs.python.org/3/library/exceptions.html.
-
Hettinger, R. "The Mental Game of Python" (PyCon 2019 talk). (Tier 1) Raymond Hettinger, a Python core developer, discusses Pythonic thinking including EAFP, duck typing, and how experienced Python developers approach error handling differently from beginners. The talk is entertaining and the lessons are actionable. Available on YouTube.
EAFP and Pythonic Style
-
Peters, T. "The Zen of Python" (
import this). (Tier 1) The guiding philosophy of Python. Several aphorisms relate directly to error handling: "Errors should never pass silently. Unless explicitly silenced." and "In the face of ambiguity, refuse the temptation to guess." Runimport thisin a Python REPL to read all 19 aphorisms. -
Python Glossary: "EAFP" and "LBYL." (Tier 1) Python's official glossary entries for both concepts. Brief but authoritative. Available at docs.python.org/3/glossary.html.
Software Reliability and Defensive Programming
-
Leveson, N. & Turner, C. (1993). "An Investigation of the Therac-25 Accidents." IEEE Computer, 26(7), 18-41. (Tier 1) The definitive account of the Therac-25 radiation therapy accidents. This paper is widely used in software engineering courses to illustrate the consequences of inadequate error handling and testing. Technical but readable.
-
SEC. (2013). "In the Matter of Knight Capital Americas LLC." Release No. 70694. (Tier 1) The SEC's official report on the Knight Capital trading incident. Publicly available and provides a detailed timeline of the failure. Reading a regulatory document about a software bug is a unique and sobering experience.
-
McConnell, S. (2004). Code Complete, 2nd Edition. Microsoft Press. (Tier 1) Chapter 8 ("Defensive Programming") and Chapter 22 ("Developer Testing") are directly relevant to this chapter's topics. McConnell's treatment of error handling is practical and language-agnostic. A classic software engineering reference.
Exception Handling Best Practices
-
Slatkin, B. (2019). Effective Python, 2nd Edition. Addison-Wesley. (Tier 1) Items 65-67 cover exception handling patterns: "Take Advantage of Each Block in try/except/else/finally," "Consider contextlib and with Statements for Reusable try/finally Behavior," and "Prefer Raising Exceptions to Returning None." Concise, actionable advice.
-
Ramalho, L. (2022). Fluent Python, 2nd Edition. O'Reilly. (Tier 2) Chapter 19 covers context managers and the
withstatement in depth, explaining how they automate the try/finally pattern for resource management. More advanced than this chapter but valuable context for understanding whywithexists.
For the Curious
-
Nygard, M. T. (2018). Release It!, 2nd Edition. Pragmatic Bookshelf. (Tier 2) A book about building software that survives production. The "Stability Patterns" chapters cover circuit breakers, bulkheads, and timeout patterns — industrial-strength versions of the error handling concepts in this chapter. The Knight Capital case study draws from similar real-world incidents discussed here.
-
Allspaw, J. (2012). "Fault Injection in Production." ACM Queue. (Tier 2) Describes how companies like Netflix deliberately introduce errors into their production systems (Chaos Monkey) to verify that error handling works correctly. A fascinating approach that takes "test your error handling" to the extreme.