Hyperlinkv0.8.0-beta.28

Effect

Effect.failconsteffect/Effect.ts:1478
<E>(error: E): Effect<never, E>

Creates an Effect that represents a recoverable error.

When to use

Use to explicitly signal a recoverable error in an Effect.

Details

The error keeps propagating unless it is handled. You can handle tagged errors with functions like catchTag or catchTags.

Example (Creating a failed effect)

import { Data, Effect } from "effect"

class OperationFailedError extends Data.TaggedError("OperationFailedError")<{}> {}

//      ┌─── Effect<never, OperationFailedError, never>
//      ▼
const failure = Effect.fail(
  new OperationFailedError()
)
Source effect/Effect.ts:14781 lines
export const fail: <E>(error: E) => Effect<never, E> = internal.fail
Referenced by 49 symbols