Errors and optional results
This chapter introduces use cases related to errors and optional values, including special uses of
There are two primary types of errors:
Program-generated errors that are returned as values.
Errors that result from exceptional control flow operation.
switchsupports general pattern-matching; point to broader discussion of
switchand pattern matching
handle errors as values with
design question in an API: When to use which?
handle errors as exceptions with
try--- in a way, these are less general for API design; may only appear in certain (
async) contexts. But they can recover from errors that would otherwise be fatal (such as system errors), so they are necessary.
discuss programming examples:
discuss use of Result module, with examples
discuss use of Option, with examples
discuss use of error-types and exceptions versus traps