1.7 KiB
1.7 KiB
title | description | menu | weight | introduced | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
experimental.catch() function | `experimental.catch()` calls a function and returns any error as a string value. If the function does not error the returned value is made into a string and returned. |
|
101 | 0.174.0 |
experimental.catch()
calls a function and returns any error as a string value.
If the function does not error the returned value is made into a string and returned.
Function type signature
(fn: () => A) => {value: A, msg: string, code: uint}
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
Parameters
fn
({{< req >}}) Function to call.
Examples
Catch an explicit error
import "experimental"
experimental.catch(fn: () => die(msg: "error message"))// Returns "error message"