Skip to content

Functions Errors

Paul Squires edited this page Oct 19, 2026 · 1 revision

Home › Function Finder › Errors and missing values

Errors and missing values

The functions to return a failure or "no value" that the caller has to check, grouped by what you want to do. The From column says what a program needs before it can call one:

  • built-in: nothing; it is always available.
  • std/outcome: #import "std/outcome", then using outcome to call it by its bare name.

Jump to: Return a value or the reason it failed · Return a value that may be missing · Catch runtime errors in a handler · Find out what went wrong · Raise an error yourself

Return a value or the reason it failed

Function What it does From
Result Holds either a value or the reason it could not be made; a new one counts as failed. std/outcome
Ok Returns a successful Result holding the value; both types must be written out. std/outcome
Fail Returns a failed Result holding the reason; both types must be written out. std/outcome
Result.IsOk Returns true if the Result holds a value rather than a reason for failure. std/outcome
Result.Value Returns the value by reference; raises an error if the Result failed. std/outcome
Result.Failure Returns the reason by reference; raises an error if the Result succeeded. std/outcome
Result.ValueOr Returns the value, or the fallback you pass if the Result failed. std/outcome

Return a value that may be missing

Function What it does From
Optional Holds one value or nothing at all; a new one is empty. std/outcome
Some Returns an Optional holding the value, its type taken from the argument. std/outcome
None Returns an empty Optional of the type you write out. std/outcome
Optional.HasValue Returns true if the Optional holds a value. std/outcome
Optional.Value Returns the value by reference; raises an error if the Optional is empty. std/outcome
Optional.ValueOr Returns the value, or the fallback you pass if the Optional is empty. std/outcome
Optional.Clear Empties the Optional, releasing whatever its value held. std/outcome

Catch runtime errors in a handler

Function What it does From
On Error Sets a label to jump to when a runtime error happens; On Error Goto 0 turns it off. built-in
Local Marks an On Error handler as belonging to the procedure it is set in. built-in

Find out what went wrong

Function What it does From
Err Returns the number of the last runtime error, or sets it without jumping. built-in
Erl Returns the source line of the last runtime error, or 0 if there was none. built-in
Erfn Returns a pointer to the name of the failing procedure; null unless built with -exx. built-in
Ermn Returns a pointer to the name of the source file where the last error happened. built-in

Raise an error yourself

Function What it does From
Error Raises a runtime error by number: jumps to the handler, or ends the program. built-in

See Also


Home · Function Finder · Keyword Index

Clone this wiki locally