effect-io-ai

Package: effect
Module: Cause

Cause.match

Transforms a Cause into a single value using custom handlers for each possible case.

Details

This function processes a Cause by applying a set of custom handlers to each possible type of cause: Empty, Fail, Die, Interrupt, Sequential, and Parallel. The result of this function is a single value of type Z. This function allows you to define exactly how to handle each part of a Cause, whether it’s a failure, defect, interruption, or a combination of these.

The options parameter provides handlers for:

Signature

declare const match: { <Z, E>(options: { readonly onEmpty: Z; readonly onFail: (error: E) => Z; readonly onDie: (defect: unknown) => Z; readonly onInterrupt: (fiberId: FiberId.FiberId) => Z; readonly onSequential: (left: Z, right: Z) => Z; readonly onParallel: (left: Z, right: Z) => Z; }): (self: Cause<E>) => Z; <Z, E>(self: Cause<E>, options: { readonly onEmpty: Z; readonly onFail: (error: E) => Z; readonly onDie: (defect: unknown) => Z; readonly onInterrupt: (fiberId: FiberId.FiberId) => Z; readonly onSequential: (left: Z, right: Z) => Z; readonly onParallel: (left: Z, right: Z) => Z; }): Z; }

Source

Since v2.0.0