Builtin expressions, operators and functions may raise errors under various conditions. An example is a mismatching type.
The evaluation of a JSONiq expression either returns a sequence of items, or raises an error.
Errors can be reported statically, or dynamically (at runtime).
Errors can also be raised by hand.
Example 15.1. Raising an error (failing).
Lazy evaluation and optimizations with regard to errors are allowed. Raising errors is not always deterministic, as in some cases the processor might (but is not required to) stop evaluating the operands of an expression if it determines that only one possible value can be returned by that expression. The following expression may return true, or may raise an error.
Example 15.2. Non-deterministic behavior (no guarantee of failure or success).
true or error()
Results:
true