Skip to content

Commit 9a279b0

Browse files
mpvlcueckoo
authored andcommitted
doc/ref/spec.md: document error builtin
Issue #291 Issue #943 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I8121ab402d97902c86fee1aaa31d1c0a5d036541 Dispatch-Trailer: {"type":"trybot","CL":1217233,"patchset":3,"ref":"refs/changes/33/1217233/3","targetBranch":"master"}
1 parent 7777230 commit 9a279b0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

doc/ref/spec.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,6 +2671,21 @@ b: "Hello \( a )!" // Hello World!
26712671

26722672
Builtin functions are predeclared. They are called like any other function.
26732673

2674+
### `error`
2675+
2676+
`error` allows user to create an error value with a custom message.
2677+
An error value can be used in a disjunction, where it will be discarded if
2678+
there is a valid disjunct, but it will be reported as the sole error value in
2679+
case all disjuncts fail.
2680+
2681+
`error` takes a single string argument. If this argument is a literal
2682+
interpolation, it will be extra resilient: if any of the arguments to the
2683+
interpolation fail, they will be printed as an expression. This allows failing
2684+
expressions to be a part of the error message.
2685+
2686+
```
2687+
a: 1/0 | error("infinity and beyond!: \(1/0)")
2688+
```
26742689

26752690
### `len`
26762691

0 commit comments

Comments
 (0)