Further Reading: Exception Handling
Official Documentation
-
Free Pascal Reference Guide — Exceptions https://www.freepascal.org/docs-html/ref/refch17.html The official Free Pascal documentation on
try..except,try..finally, raising exceptions, and the exception class hierarchy. -
Free Pascal RTL — SysUtils Exception Classes https://www.freepascal.org/docs-html/rtl/sysutils/exception.html Reference for the
Exceptionbase class and all standard exception types (EConvertError,EInOutError,ERangeError, etc.).
Books
-
Michael Feathers, Working Effectively with Legacy Code (2004) While not Pascal-specific, this book provides excellent guidance on introducing exception handling and testability into existing codebases. Relevant for anyone maintaining Pascal code that uses
IOResult-style error handling. -
Marco Cantu, Object Pascal Handbook (latest edition) Chapter on exception handling covers Delphi-specific features, many of which apply directly to Free Pascal. Good coverage of exception handling in component-based architectures.
-
Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship (2008) Chapter 7, "Error Handling," provides language-agnostic best practices for exception handling: prefer exceptions over return codes, write try blocks first, define exception classes for your domain, and never return null.
Articles and Online Resources
-
"Exception Handling" — Free Pascal Wiki https://wiki.freepascal.org/Exceptions Practical guide to exception handling in Free Pascal, including differences from Delphi and common patterns.
-
"Error Handling Patterns" — Martin Fowler https://martinfowler.com/articles/replaceThrowWithNotification.html Fowler's article on the Notification pattern as an alternative to exceptions for validation — relevant to the "do not use exceptions for flow control" discussion.
Related Chapters in This Textbook
- Chapter 13: File I/O — Covered
IOResultand{$I-}`/`{$I+}error handling. This chapter replaces those patterns with exceptions for new code. - Chapter 16: Classes and Objects — The Create-Try-Finally pattern for object lifetimes depends on exception handling.
- Chapter 18: Interfaces — Interface reference counting interacts with exception handling: interface variables are automatically freed when exceptions cause them to go out of scope.
- Chapter 20: Generics — Generic collections can raise exceptions when type constraints are violated or indices are out of range.
- Chapter 31: Database Programming — Database operations are one of the most exception-heavy areas in application development.
- Chapter 35: Networking — Network operations fail frequently and unpredictably; exception handling is essential.