/** * Error classification system for xopc * * Provides structured error types for better handling and user feedback. */ export type ErrorCategory = 'user' | 'config' | 'system' | 'network' | 'provider'; declare const XOPC_ERROR_MARKER: unique symbol; declare const USER_ERROR_MARKER: unique symbol; declare const CONFIG_ERROR_MARKER: unique symbol; declare const SYSTEM_ERROR_MARKER: unique symbol; declare const NETWORK_ERROR_MARKER: unique symbol; declare const PROVIDER_ERROR_MARKER: unique symbol; export interface ErrorDetails { code: string; category: ErrorCategory; message: string; suggestion?: string; retryable?: boolean; } /** * Base error class for all xopc errors */ export declare class XopcError extends Error { readonly [XOPC_ERROR_MARKER] = true; readonly code: string; readonly category: ErrorCategory; readonly retryable: boolean; readonly suggestion?: string; readonly cause?: Error; constructor(details: ErrorDetails, cause?: Error); /** * Format error for user display */ toUserMessage(): string; /** * Format error for logging */ toLogObject(): Record; } /** * User input/operation errors - caused by user actions */ export declare class UserError extends XopcError { readonly [USER_ERROR_MARKER] = true; constructor(code: string, message: string, suggestion?: string, cause?: Error); static invalidCommand(command: string): UserError; static invalidInput(message: string, suggestion?: string): UserError; static unauthorized(message?: string): UserError; } /** * Configuration errors - caused by invalid/missing config */ export declare class ConfigError extends XopcError { readonly [CONFIG_ERROR_MARKER] = true; constructor(code: string, message: string, suggestion?: string, cause?: Error); static missingApiKey(provider: string): ConfigError; static invalidConfig(path: string, reason: string): ConfigError; static missingConfig(key: string): ConfigError; } /** * System errors - internal/system-level failures */ export declare class SystemError extends XopcError { readonly [SYSTEM_ERROR_MARKER] = true; constructor(code: string, message: string, retryable?: boolean, suggestion?: string, cause?: Error); static internal(message: string, cause?: Error): SystemError; static filesystem(path: string, operation: string, cause?: Error): SystemError; static outOfMemory(): SystemError; } /** * Network errors - connectivity/timeout issues */ export declare class NetworkError extends XopcError { readonly [NETWORK_ERROR_MARKER] = true; constructor(code: string, message: string, retryable?: boolean, suggestion?: string, cause?: Error); static timeout(url: string, timeoutMs: number, cause?: Error): NetworkError; static connectionFailed(url: string, cause?: Error): NetworkError; } /** * LLM Provider errors - model/API failures */ export declare class ProviderError extends XopcError { readonly [PROVIDER_ERROR_MARKER] = true; readonly provider: string; readonly model?: string; readonly statusCode?: number; constructor(provider: string, code: string, message: string, retryable?: boolean, suggestion?: string, cause?: Error, statusCode?: number, model?: string); static rateLimit(provider: string, retryAfter?: number, model?: string): ProviderError; static authFailed(provider: string, cause?: Error): ProviderError; static modelNotFound(provider: string, model: string): ProviderError; static overloaded(provider: string, model?: string): ProviderError; static insufficientFunds(provider: string): ProviderError; } /** * Error handling utilities */ export declare function isXopcError(error: unknown): error is XopcError; export declare function isUserError(error: unknown): error is UserError; export declare function isConfigError(error: unknown): error is ConfigError; export declare function isProviderError(error: unknown): error is ProviderError; export declare function isRetryable(error: unknown): boolean; /** * Wrap unknown error into XopcError */ export declare function wrapError(error: unknown, context?: string): XopcError; /** * Format error for user display */ export declare function formatErrorForUser(error: unknown): string; /** * Format error for logging */ export declare function formatErrorForLog(error: unknown): Record; export {};