docs-v2/content/flux/v0/stdlib/experimental/catch.md

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.
flux_v0_ref
name parent identifier
experimental.catch experimental experimental/catch
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"