Hyperlinkv0.8.0-beta.28

Cause

Cause.YieldableErrorinterfaceeffect/Cause.ts:1187
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
})
errors
Source effect/Cause.ts:11874 lines
export interface YieldableError extends Error, Pipeable, Inspectable {
  readonly [Effect.TypeId]: Effect.Variance<never, this, never>
  [Symbol.iterator](): Effect.EffectIterator<Effect.Effect<never, this, never>>
}
Referenced by 10 symbols