Hyperlinkv0.8.0-beta.28

Runtime

Runtime.errorExitCodetypeeffect/Runtime.ts:264
"~effect/Runtime/errorExitCode"

Type-level key for the Runtime.errorExitCode marker.

When to use

Use to type properties keyed by Runtime.errorExitCode on custom error values.

symbols
Source effect/Runtime.ts:26444 lines
export type errorExitCode = "~effect/Runtime/errorExitCode"

/**
 * Allows associating an exit code with an error for determining the process
 * exit code on failure.
 *
 * **When to use**
 *
 * Use when error classes should map failures to a specific process exit code
 * when handled by {@link defaultTeardown}.
 *
 * **Details**
 *
 * Attach this marker as a readonly property on an error object. When the main
 * program fails, {@link defaultTeardown} squashes the Cause and reads the marker
 * from the resulting error value.
 *
 * **Gotchas**
 *
 * The marker is read from the squashed failure value. If a Cause contains
 * multiple failures, the selected squashed error determines the exit code.
 *
 * **Example** (Setting a process exit code)
 *
 * ```ts
 * import { Data, Effect, Runtime } from "effect"
 * import { NodeRuntime } from "@effect/platform-node"
 *
 * class MyError extends Data.TaggedError("MyError") {
 *   readonly [Runtime.errorExitCode] = 42
 * }
 *
 * // If the program fails with MyError, the process will exit with code 42
 * NodeRuntime.runMain(Effect.fail(new MyError()))
 * ```
 *
 * @see {@link errorReported} for controlling automatic error logging
 * @see {@link defaultTeardown} for the default failure exit-code rules that read this marker
 * @see {@link getErrorExitCode} for reading the marker from unknown error values
 *
 * @category symbols
 * @since 4.0.0
 */
export const errorExitCode: errorExitCode = "~effect/Runtime/errorExitCode"
Referenced by 1 symbols