Hyperlinkv0.8.0-beta.28

Cause

Cause.findErrorconsteffect/Cause.ts:841
<E>(self: Cause<E>): Result.Result<E, Cause<never>>

Returns a Result whose success value is the first typed error value E from a Fail reason in the cause. If the cause has no Fail reason, the failure value is the original cause narrowed to Cause<never>, because it contains no typed error reasons.

When to use

Use when you need the first typed error value from a Cause as a Result that preserves the original cause when no match is found.

Example (Extracting the first error value)

import { Cause, Result } from "effect"

const result = Cause.findError(Cause.fail("error"))
if (!Result.isFailure(result)) {
  console.log(result.success) // "error"
}
Source effect/Cause.ts:8411 lines
export const findError: <E>(self: Cause<E>) => Result.Result<E, Cause<never>> = effect.findError
Referenced by 3 symbols