effect-io-ai

Package: effect
Module: Cause

Cause.YieldableError

Base interface for error classes that can be yielded directly inside Effect.gen. Yielding one of these errors fails the generator with that error as the typed failure value.

Details

All built-in error classes in this module (NoSuchElementError, TimeoutError, IllegalArgumentError, ExceededCapacityError, AsyncFiberError, and UnknownError) implement this interface.

Example (Yielding an error in Effect.gen)

import { Cause, Effect } from "effect"

const error = new Cause.NoSuchElementError("not found")

const program = Effect.gen(function*() {
  return yield* error // fails the effect with NoSuchElementError
})

Signature

export interface YieldableError extends Error, Pipeable, Inspectable {
  readonly [Effect.TypeId]: Effect.Variance<never, this, never>
  [Symbol.iterator](): Effect.EffectIterator<Effect.Effect<never, this, never>>
}

Source

Since v2.0.0