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).
- Import:
@kjanat/dreamcli - Export kind: class
- Declared in:
src/core/errors/index.ts - Source link:
src/core/errors/index.ts:65
Signatures
class CLIError extends Error {}Members
Constructors
constructor
Create a structured CLI error from a human message and machine-readable options.
constructor(message: string, options: CLIErrorOptions);Properties
name
Error class name, always 'CLIError' for the base class. @override
name: string;code
Stable machine-readable identifier.
code: ErrorCode;exitCode
Process exit code (defaults to 1).
exitCode: number;suggest
One-liner actionable hint.
suggest: string | undefined;details
Structured payload for machine output.
details: Readonly<Record<string, unknown>> | undefined;message
message: string;stack
stack?: string | undefined;cause
cause?: unknown;isError
Indicates whether the argument provided is a built-in Error instance or not.
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.
toJSON(): CLIErrorJSON;Related Examples
- Mixed machine-readable JSON and human-readable side-channel output. -
examples/json-mode.ts - Middleware patterns: auth guard, request timing, error handling. -
examples/middleware.ts