Exceptionless error management
The OCaml standard library uses exceptions to signal unexceptional error cases. The canonical example is to raise
Not_found to signal the absence of a result (
List.find etc.). However there are a number of disavantages in doing so, the principal ones being enumerated below.
- It is not apparent in the type of the function that they may disrupt the control flow. This fact needs to be textually documented.
- The typechecker doesn't signal us when we do not handle these error cases even though they need to be handled for program correctness.
- Exception handlers make it more complicated to write tail recursive functions.
Two candidate recommendations have been drafted:
- OSR/Exceptionless Error Management/Recommendation Candidate 1
- OSR/Exceptionless Error Management/Recommendation Candidate 2