Skip to content

CLIError ​

Base structured error for DreamCLI.

Every error surfaced by the framework extends this class, ensuring a consistent shape for rendering (TTY pretty-print, --json, test assertions).

Signatures ​

ts
class CLIError extends Error {}

Members ​

Constructors ​

constructor ​

Create a structured CLI error from a human message and machine-readable options.

ts
constructor(message: string, options: CLIErrorOptions);

Properties ​

name ​

Error class name, always 'CLIError' for the base class. @override

ts
name: string;

code ​

Stable machine-readable identifier.

ts
code: ErrorCode;

exitCode ​

Process exit code (defaults to 1).

ts
exitCode: number;

suggest ​

One-liner actionable hint.

ts
suggest: string | undefined;

details ​

Structured payload for machine output.

ts
details: Readonly<Record<string, unknown>> | undefined;

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;

Methods ​

toJSON ​

Serialise to a plain object suitable for JSON output.

details is projected onto JSON-representable values: bigints become decimal digits and entries JSON cannot carry are omitted. The error object itself keeps the runtime values.

ts
toJSON(): CLIErrorJSON;

See Also ​

Released under the MIT License.