Whether value is an Error carrying one of the given Node code strings — ENOENT,
EADDRINUSE, EBUSY. With no codes it matches any error that has a string code at all
(which includes Node's ERR_* internal errors, e.g. ERR_MODULE_NOT_FOUND).
Calls fn(...args) and returns the value bare, classifying any throw into the
declared Failure classify builds — the boundary and the declaration fused into one
expression, producing the bare union directly. The sync sibling of Task#mapErr: like
that adapter edge it deliberately catches everything, because this IS the edge where a
foreign throw becomes a declared failure — chain the original under cause. When the
boundary should stay raw and the declaration should be a separate visible rethrow line,
use Result.try instead.
Calls fn(...args) and reflects the outcome into a Caught box — Result.try, shaped like
Promise.try. See the module doc for the flat-classification pattern this is half of.
Minimal shape of a Node system error, declared locally so this module stays runtime-free.
-
code: string
The symbolic error code, e.g.
ENOENT. What isErrno matches on. -
errno: number
The negated platform errno number.
-
path: string
The path the failing call was operating on, when the syscall takes one.
-
syscall: string
The syscall that failed, e.g.
open.
What the boundary hands back: the value, or whatever was caught — unknown, honestly,
because a catch binding is exactly as untrustworthy.
The caught variant. value is present-but-undefined for shape stability.
The success variant of a caught outcome. error is present-but-undefined for shape stability.
The outcome of rescue(): the bare T | F union, promise-wrapped when fn was async.
A leaking any collapses to unknown so it cannot pose as an inspected type.
Usage
import * as mod from "lib/result/try.ts";