effect-io-ai

Package: effect
Module: Exit

Exit.filterCause

Extracts the Cause from a failed Exit as a Result.

When to use

Use when composing Exit checks with Filter or other Result-based filtering APIs and you want the raw Cause rather than the Failure wrapper.

Details

Returns Result.succeed(cause) when the Exit is a Failure, or Result.fail(success) with the original Success otherwise.

Gotchas

This is not an Option accessor or an Effect failure. A failed extraction is represented as data in the Result failure channel.

Example (Filtering for the cause)

import { Exit, Result } from "effect"

const exit = Exit.fail("err")
const result = Exit.filterCause(exit)

console.log(Result.isSuccess(result)) // true

See

Signature

declare const filterCause: <A, E>(self: Exit<A, E>) => Result.Result<Cause.Cause<E>, Success<A>>

Source

Since v4.0.0