Failure is a condition in software or its environment where a computation or requested operation cannot produce its intended result. In engineering terms, errors are usually expected or possible erroneous states, while exceptions are language-dependent mechanisms for interrupting control flow when something unexpected occurs. section 13.1.1 section 13.3
Treat failure according to its kind and boundary:
- Handle errors explicitly as probable states associated with particular circumstances or domains. section 13.1.1
- Reserve exceptions for unexpected conditions and understand that uncaught exceptions may terminate execution to prevent further corruption or security breaches. section 13.1.1
- Abstract native errors at domain boundaries so external libraries and language ecosystems do not couple business logic to implementation details. section 13.1.1
- Divide applications into error domains, giving each domain an appropriate handling strategy and converting representations at its boundaries. section 13.3
One situation, two failure mechanisms
A probable, domain-related erroneous situation is an error and belongs in explicit handling. An unexpected condition caused by a likely bug is exceptional and may interrupt evaluation through an implicit control flow. Languages and practices differ: Haskell supports several exception and error-handling mechanisms, while Rust has no exceptions as a language feature. section 13.1.1 section 13.3











