Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Missing values and failures

Programs usually need to represent two different cases:

  • a value is genuinely absent
  • an operation failed and execution should stop or recover

Acton uses different tools for those cases. None and optional types model ordinary absence. Exceptions model failures.

Use an optional when absence is part of the normal result. Use an exception when the operation could not finish as intended. A caller can branch on an optional; an exception means the current path should stop unless it is explicitly handled.

There is no Rust-style match path for this in Acton. Use ordinary branching, optional checks, and exception handling instead.

Start here when you need to decide whether a function should return None, raise an exception, or let an expression keep propagating an optional result.

Optional chaining and forced unwrapping are expression-level tools. They do not replace the type system or exception handling; they make the common cases shorter. Keep absence in the type when it is expected, and reserve exceptions for broken assumptions, invalid input, and other failures that should not be treated as routine control flow.