Skip to content

ExitError ​

Error thrown by adapter implementations that model process exit as an exception instead of terminating immediately.

Runtime and CLI dispatch layers can catch this to perform real process termination, while tests can assert on exit codes without killing the runner:

ts
try {
  await cli.run({ adapter: createTestAdapter() });
} catch (e) {
  if (e instanceof ExitError) expect(e.code).toBe(0);
}

Signatures ​

ts
class ExitError extends Error {}

Members ​

Constructors ​

constructor ​

Create an ExitError for the given process exit code.

ts
constructor(code: number);

Properties ​

name ​

Error name — always 'ExitError' for instanceof checks.

ts
name: string;

code ​

The exit code passed to exit().

ts
code: number;

message ​

ts
message: string;

stack ​

ts
stack?: string | undefined;

cause ​

ts
cause?: unknown;

isError ​

Indicates whether the argument provided is a built-in Error instance or not.

ts
isError: (error: unknown) => error is Error;

See Also ​

Released under the MIT License.