interface Failure.FailureOptions

Options accepted by the Failure constructor and by every generated factory.

Properties

optional
cause: unknown

The error this failure was derived from. Preserved verbatim and walked by causes().

optional
stackless: boolean

Skips stack capture. Only worth setting for failures produced in a hot loop and consumed immediately — the capture, not the allocation, is what a Failure costs. See the performance section of the docs before reaching for it.

optional
stackAnchor: (...args: never[]) => unknown

The function to truncate the stack at, so the top frame is the code that reported the failure rather than the plumbing that built it. Defaults to the constructor.

Anything that wraps define() in another layer needs this, and so does define() itself: eliding only the constructor leaves the factory's own frame on top, which is how a Failure ends up pointing at failure.ts instead of at the caller.

Usage

import { type Failure } from "lib/result/index.ts";
type { FailureOptions } = Failure;