err
Constructs a failure Result. Normalizes any thrown value into an Error.
Usage
err(reason)
Pass an Error, a string, or any other value. Strings are wrapped in new Error(reason). Non-error, non-string values get JSON.stringify'd into the message and the original is preserved on error.cause.
Parameters
reasonunknownrequired
the failure value. Accepts anything — normalization to Error is the function's job.
Returns
{ ok: false, value: null, error: Error }.
See also
ok— construct a success resultattempt— wrap an unsafe call- Result & Errors concept guide