Hyperlinkv0.8.0-beta.28

Cause

Cause.findErrorOptionconsteffect/Cause.ts:869
<E>(input: Cause<E>): Option<E>

Returns the first typed error value E from a cause wrapped in Option.some, or Option.none if no Fail reason exists.

When to use

Use when you need the first typed error value from a Cause as an Option, discarding the original cause.

Example (Extracting an error as Option)

import { Cause, Option } from "effect"

const some = Cause.findErrorOption(Cause.fail("error"))
console.log(Option.isSome(some)) // true

const none = Cause.findErrorOption(Cause.die("defect"))
console.log(Option.isNone(none)) // true
filteringfindError
Source effect/Cause.ts:8691 lines
export const findErrorOption: <E>(input: Cause<E>) => Option<E> = effect.findErrorOption