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 ​

ts
constructor();

Properties ​

cause ​

The cause of the error.

ts
cause?: unknown;

code ​

The exit code passed to exit().

ts
code: number;

message ​

ts
message: string;

name ​

Error name — always 'ExitError' for instanceof checks.

ts
name: "ExitError";

stack ​

ts
stack?: string;

stackTraceLimit ​

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

ts
stackTraceLimit: number;

Methods ​

captureStackTrace ​

ts
captureStackTrace(targetObject: object, constructorOpt?: Function): void;

isError ​

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

prepareStackTrace ​

ts
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;

See Also ​

Released under the MIT License.