Hyperlinkv0.8.0-beta.28

Runtime

Runtime.getErrorExitCodeconsteffect/Runtime.ts:333
(u: unknown): number

Reads the runtime exit-code marker from an unknown error value.

When to use

Use to read a custom failure exit code from an unknown error value, falling back to the default failure code.

Details

Returns the numeric [Runtime.errorExitCode] property when it is present on an object. Otherwise returns 1, the default failure exit code used by defaultTeardown.

Gotchas

Non-object values, missing markers, and non-number marker values all return 1.

accessorserrorExitCode
Source effect/Runtime.ts:3339 lines
export const getErrorExitCode = (u: unknown): number => {
  if (typeof u === "object" && u !== null && errorExitCode in u) {
    const code = u[errorExitCode]
    if (typeof code === "number") {
      return code
    }
  }
  return 1
}
Referenced by 1 symbols