Обзор
functionComposition

fail

Creates a behavior that always fails with the same domain error.

Signature

tsSignature
export function fail<E>(error: E): Behavior<unknown, never, E>;

Imports

tsImport
import { fail } from "@/lib/flow/fail";
import { fail } from "@/lib/flow";

Type Parameters

E

Domain error type.

Parameters

error
E

Error value returned for every execution.

Returns

A behavior that ignores input and returns `Err`.

Return type
Behavior<unknown, never, E>

Details

Use `fail` for fallback branches, tests, and workflow construction where a known typed failure is

the intended result.

Examples

tsExample
const unavailable = fail({ kind: "offline" });
Behavior

Executable Flow workflow unit.

type

Source

tsflow/fail.ts:19-21
export function fail<E>(error: E): Behavior<unknown, never, E> {
return task<unknown, never, E>((_input, context) => context.fail(error));
}