Package: effect
Module: Cause
Collapses a Cause into a single unknown value, picking the “most
important” failure in this order:
When to use
Use to collapse a structured cause to the single value that synchronous and promise runners would throw.
Details
Fail error (the E value)Die defectError("All fibers interrupted without error") for interrupt-only causesError("Empty cause") for emptyThis is the function used by Effect.runPromise and Effect.runSync to
decide what to throw.
Gotchas
This function is lossy. Use prettyErrors or iterate cause.reasons
when you need all failures.
Example (Squashing a cause)
import { Cause } from "effect"
console.log(Cause.squash(Cause.fail("error"))) // "error"
console.log(Cause.squash(Cause.die("defect"))) // "defect"
See
prettyErrors — non-lossy conversion to Array<Error>pretty — human-readable string renderingSignature
declare const squash: <E>(self: Cause<E>) => unknown
Since v2.0.0