effect-io-ai

Package: effect
Module: Runtime

Runtime.defaultTeardown

The default teardown function that determines exit codes from an Effect exit.

When to use

Use as the standard teardown for main programs with conventional process exit codes and support for errorExitCode.

Details

This teardown follows these exit-code rules:

Gotchas

The 130 code is used only when the Cause contains interruptions and no other failure reasons. Mixed causes use the squashed error path instead.

Example (Referencing default teardown)

import { Exit, Runtime } from "effect"

const logExitCode = (exit: Exit.Exit<any, any>) => {
  Runtime.defaultTeardown(exit, (code) => {
    console.log(`Exit code: ${code}`)
  })
}

logExitCode(Exit.succeed(42))
// Output: Exit code: 0

logExitCode(Exit.fail("error"))
// Output: Exit code: 1

logExitCode(Exit.interrupt(123))
// Output: Exit code: 130

See

Signature

declare const defaultTeardown: Teardown

Source

Since v4.0.0