/** * AppError — base class for all application errors. * * Use a subclass (NetworkError, PlatformError, etc.) — never instantiate AppError directly * in production code. The class identity (`error.name`) is the category; `context` carries * the specifics; `cause` chains the underlying error. * * `instanceof` is the supported way to branch on error type. `toJSON()` is what the * existing logger's safeStringify uses to produce structured output, so logging an * AppError preserves the full chain automatically. */ export interface ErrorContext { [key: string]: unknown; } export interface SerializedError { name: string; message: string; context: ErrorContext; stack?: string; cause?: SerializedError; timestamp: string; } export interface AppErrorOptions { cause?: unknown; context?: ErrorContext; } export declare class AppError extends Error { readonly context: ErrorContext; readonly timestamp: Date; constructor(message: string, options?: AppErrorOptions); serialize(): SerializedError; /** * Called automatically by JSON.stringify so `safeStringify({ error })` in the logger * produces the full structured form without any logger changes. */ toJSON(): SerializedError; }