<E>(error: E): Fail<E>Creates a standalone Fail reason (not wrapped in a Cause).
When to use
Use when constructing a standalone typed failure reason for fromReasons or direct comparison.
Example (Creating a Fail reason)
import { Cause } from "effect"
const reason = Cause.makeFailReason("error")
console.log(reason._tag) // "Fail"
console.log(reason.error) // "error"Source effect/Cause.ts:5641 lines
export const const makeFailReason: <E>(
error: E
) => Fail<E>
Creates a standalone Fail reason (not wrapped in a Cause).
When to use
Use when constructing a standalone typed failure reason for
fromReasons
or direct comparison.
Example (Creating a Fail reason)
import { Cause } from "effect"
const reason = Cause.makeFailReason("error")
console.log(reason._tag) // "Fail"
console.log(reason.error) // "error"
makeFailReason = <function (type parameter) E in <E>(error: E): Fail<E>E>(error: Eerror: function (type parameter) E in <E>(error: E): Fail<E>E): interface Fail<out E>A typed, expected error produced by Effect.fail.
When to use
Use when inspecting Cause reasons that represent expected failures from the
typed error channel.
Details
The error property carries the typed value E. Use
isFailReason
to narrow a Reason to this type.
Example (Accessing the error)
import { Cause } from "effect"
const cause = Cause.fail("Something went wrong")
const reason = cause.reasons[0]
if (Cause.isFailReason(reason)) {
console.log(reason.error) // "Something went wrong"
}
Fail<function (type parameter) E in <E>(error: E): Fail<E>E> => new import corecore.constructor Fail<E>(error: E, annotations?: Map<string, unknown>): core.Fail<E>Fail(error: Eerror)Referenced by 1 symbols