<E>(self: Reason<E>): self is Fail<E>Narrows a Reason to Fail.
When to use
Use as a predicate for Array.filter to pick out typed Fail reasons when
iterating over cause.reasons.
Example (Filtering fail reasons)
import { Cause } from "effect"
const cause = Cause.fail("error")
const fails = cause.reasons.filter(Cause.isFailReason)
console.log(fails[0].error) // "error"export const const isFailReason: <E>(
self: Reason<E>
) => self is Fail<E>
Narrows a Reason to Fail.
When to use
Use as a predicate for Array.filter to pick out typed Fail reasons when
iterating over cause.reasons.
Example (Filtering fail reasons)
import { Cause } from "effect"
const cause = Cause.fail("error")
const fails = cause.reasons.filter(Cause.isFailReason)
console.log(fails[0].error) // "error"
isFailReason: <function (type parameter) E in <E>(self: Reason<E>): self is Fail<E>E>(self: Reason<E>self: type Reason<E> = Fail<E> | Die | InterruptA single entry inside a Cause's reasons array.
Details
Narrow to a concrete type with
isFailReason
,
isDieReason
,
or
isInterruptReason
.
Fail<E> — typed error, access via .error
Die — untyped defect, access via .defect
Interrupt — fiber interruption, access via .fiberId
Every reason carries an annotations map and an annotate method for
attaching tracing metadata.
Example (Narrowing a reason)
import { Cause } from "effect"
const reason = Cause.fail("error").reasons[0]
if (Cause.isFailReason(reason)) {
console.log(reason.error) // "error"
}
Companion namespace for the Reason type.
Reason<function (type parameter) E in <E>(self: Reason<E>): self is Fail<E>E>) => self: Reason<E>self is 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>(self: Reason<E>): self is Fail<E>E> = import corecore.const isFailReason: <E>(
self: Cause.Reason<E>
) => self is Cause.Fail<E>
isFailReason