export interface BuildContext { file?: string; line?: number; column?: number; moduleId?: string; phase?: "parse" | "transform" | "bundle" | "optimize" | "dependency-resolution" | "circuit-breaker" | "http-bundle-validation"; /** Number of failures (for circuit breaker) */ failures?: number; /** Missing dependencies list */ missing?: Array<{ specifier: string; fromFile: string; reason: string; }>; /** Failed HTTP bundle specifiers */ failed?: string[]; /** Cache directory path */ cacheDir?: string; } export interface APIContext { endpoint?: string; method?: string; statusCode?: number; headers?: Record; } export interface RenderContext { component?: string; route?: string; phase?: "server" | "client" | "hydration"; props?: unknown; } export interface ConfigContext { configFile?: string; field?: string; value?: unknown; expected?: string; } export interface AgentContext { agentId?: string; intent?: string; timeout?: number; } export interface FileContext { path?: string; operation?: "read" | "write" | "delete" | "mkdir"; permissions?: string; } interface NetworkContext { url?: string; timeout?: number; retryCount?: number; } /** * Discriminated union for serializable error data. * * This represents error DATA (plain objects), not throwable errors. * For throwable errors, use `VeryfrontError` class from `./types.ts`. */ export type VeryfrontErrorData = { type: "build"; message: string; context?: BuildContext; } | { type: "api"; message: string; context?: APIContext; } | { type: "render"; message: string; context?: RenderContext; } | { type: "config"; message: string; context?: ConfigContext; } | { type: "agent"; message: string; context?: AgentContext; } | { type: "file"; message: string; context?: FileContext; } | { type: "network"; message: string; context?: NetworkContext; } | { type: "permission"; message: string; context?: FileContext; } | { type: "not_supported"; message: string; feature?: string; } | { type: "no_ai_available"; message: string; }; export declare function createError(error: VeryfrontErrorData): VeryfrontErrorData; export declare const isBuildError: (error: VeryfrontErrorData) => error is { type: "build"; message: string; context?: BuildContext; }; export declare const isAPIError: (error: VeryfrontErrorData) => error is { type: "api"; message: string; context?: APIContext; }; export declare const isRenderError: (error: VeryfrontErrorData) => error is { type: "render"; message: string; context?: RenderContext; }; export declare const isConfigError: (error: VeryfrontErrorData) => error is { type: "config"; message: string; context?: ConfigContext; }; export declare const isFileError: (error: VeryfrontErrorData) => error is { type: "file"; message: string; context?: FileContext; }; export declare const isNetworkError: (error: VeryfrontErrorData) => error is { type: "network"; message: string; context?: NetworkContext; }; /** * Convert a VeryfrontErrorData (plain object) to a throwable Error instance. * * Uses Error.captureStackTrace when available (V8 engines) to exclude toError() * from the stack trace, making the stack point to the actual call site. * An optional native error constructor preserves categories such as * `TypeError` while retaining the structured Veryfront error context. * * @see plans/architecture-audit/010.3-dual-veryfront-error-definitions.md */ export declare function toError(veryfrontError: VeryfrontErrorData): Error; export declare function toError(veryfrontError: VeryfrontErrorData, ErrorType: new (message?: string) => T): T; /** @internal Decode one already-extracted legacy context value. */ export declare function decodeVeryfrontErrorData(contextValue: unknown, isProxy: (value: object) => boolean): VeryfrontErrorData | null; /** * Extract error message from any error type */ export declare function getErrorMessage(error: unknown): string; /** Runtime-safe native Error guard for values caught from untrusted code. */ export declare function isErrorInstance(error: unknown): error is Error; export interface ErrorSnapshot { readonly name: string; readonly message: string; readonly stack?: string; } /** Snapshot a native Error without retaining a proxy or invoking it again later. */ export declare function snapshotError(error: unknown): ErrorSnapshot | null; export declare function snapshotKnownError(error: Error): ErrorSnapshot | null; /** * Normalize a thrown value into a detached Error snapshot. * * Use this at boundaries that retain or repeatedly inspect the result. A * transparent Proxy can pass `instanceof Error` while throwing or changing * values on a later property read. */ export declare function snapshotErrorAsError(error: unknown): Error; /** * Ensure a value is an Error while preserving the established identity * contract for ordinary Error instances. */ export declare function ensureError(error: unknown): Error; export {}; //# sourceMappingURL=veryfront-error.d.ts.map