Hyperlinkv0.8.0-beta.28

Cause

Cause.findDefectconsteffect/Cause.ts:952
<E>(self: Cause<E>): Result.Result<unknown, Cause<E>>

Returns a Result whose success value is the first defect value from a Die reason in the cause. If the cause has no Die reason, the failure value is the original cause.

When to use

Use when you need the first defect value from a Cause as a Result, without the full Die reason.

Example (Extracting the first defect)

import { Cause, Result } from "effect"

const result = Cause.findDefect(Cause.die("defect"))
if (!Result.isFailure(result)) {
  console.log(result.success) // "defect"
}
Source effect/Cause.ts:9521 lines
export const findDefect: <E>(self: Cause<E>) => Result.Result<unknown, Cause<E>> = effect.findDefect