Hyperlinkv0.8.0-beta.28

Effect

Effect.failSyncconsteffect/Effect.ts:1507
<E>(evaluate: LazyArg<E>): Effect<never, E>

Creates an Effect that represents a recoverable error using a lazy evaluation.

When to use

Use to defer computing a recoverable error value until the effect is run.

Details

The error-producing function is evaluated each time the effect is executed.

Example (Lazily creating failures)

import { Data, Effect } from "effect"

class ProgramError extends Data.TaggedError("ProgramError")<{ readonly failedAt: Date }> {}

const program = Effect.failSync(() => new ProgramError({ failedAt: new Date() }))

Effect.runPromiseExit(program).then(console.log)
// Output: { _id: 'Exit', _tag: 'Failure', cause: ... }
constructors
Source effect/Effect.ts:15071 lines
export const failSync: <E>(evaluate: LazyArg<E>) => Effect<never, E> = internal.failSync
Referenced by 2 symbols