import { ValidationError } from '../types'; /** * Error Handling Module * * Provides centralized error handling utilities including: * - Network error handling with retry mechanism * - Schema error handling with fix suggestions * - Unknown component handling with logging * * Requirements: 1.5, 2.6, 6.5 */ /** * Base error class for llm2ui errors */ export declare class LLM2UIError extends Error { /** Error code for categorization */ code: string; /** Whether the error is recoverable */ recoverable: boolean; /** Original error if this wraps another error */ cause?: Error; constructor(message: string, code: string, recoverable?: boolean, cause?: Error); } /** * Network-related error */ export declare class NetworkError extends LLM2UIError { /** HTTP status code if available */ statusCode?: number; /** Number of retry attempts made */ retryCount: number; constructor(message: string, options?: { statusCode?: number; retryCount?: number; cause?: Error; }); } /** * Schema validation error */ export declare class SchemaError extends LLM2UIError { /** Path to the error in the schema */ path: string; /** Suggested fix for the error */ suggestion?: string; constructor(message: string, path: string, options?: { suggestion?: string; cause?: Error; }); } /** * Unknown component error */ export declare class UnknownComponentError extends LLM2UIError { /** The unknown component type */ componentType: string; /** The component ID */ componentId: string; constructor(componentType: string, componentId: string); } /** * Retry configuration options */ export interface RetryConfig { /** Maximum number of retry attempts */ maxRetries: number; /** Initial delay in milliseconds */ initialDelay: number; /** Maximum delay in milliseconds */ maxDelay: number; /** Backoff multiplier */ backoffMultiplier: number; /** HTTP status codes that should trigger a retry */ retryableStatusCodes: number[]; /** Callback for retry attempts */ onRetry?: (attempt: number, error: Error, delay: number) => void; } /** * Default retry configuration */ export declare const DEFAULT_RETRY_CONFIG: RetryConfig; /** * Calculates the delay for a retry attempt using exponential backoff */ export declare function calculateRetryDelay(attempt: number, config: RetryConfig): number; /** * Determines if an error is retryable */ export declare function isRetryableError(error: unknown, config: RetryConfig): boolean; /** * Wraps a fetch call with retry logic */ export declare function fetchWithRetry(url: string, options: RequestInit, config?: Partial): Promise; /** * Network error state for UI display */ export interface NetworkErrorState { /** Whether there's an active error */ hasError: boolean; /** Error message */ message: string; /** Error code */ code: string; /** Number of retries attempted */ retryCount: number; /** Whether retry is in progress */ isRetrying: boolean; /** Timestamp of the error */ timestamp: number; } /** * Creates an initial network error state */ export declare function createNetworkErrorState(): NetworkErrorState; /** * Updates network error state from an error */ export declare function setNetworkError(error: Error, retryCount?: number): NetworkErrorState; /** * Clears network error state */ export declare function clearNetworkError(): NetworkErrorState; /** * Gets a user-friendly error message for network errors */ export declare function getNetworkErrorMessage(error: Error): string; /** * Schema error with fix suggestion */ export interface SchemaErrorWithSuggestion { /** Original validation error */ error: ValidationError; /** Suggested fix description */ suggestion: string; /** Auto-fix function if available */ autoFix?: (schema: string) => string; } /** * Gets fix suggestions for validation errors */ export declare function getSchemaErrorSuggestions(errors: ValidationError[], schema: string): SchemaErrorWithSuggestion[]; /** * Schema error display state */ export interface SchemaErrorState { /** List of errors with suggestions */ errors: SchemaErrorWithSuggestion[]; /** Whether there are any errors */ hasErrors: boolean; /** Summary message */ summary: string; } /** * Creates schema error state from validation errors */ export declare function createSchemaErrorState(errors: ValidationError[], schema: string): SchemaErrorState; /** * Unknown component log entry */ export interface UnknownComponentLog { /** Component type that was not found */ type: string; /** Component ID */ id: string; /** Timestamp when the error occurred */ timestamp: number; /** Context information */ context?: string; } /** * Unknown component logger */ declare class UnknownComponentLogger { private logs; private maxLogs; private listeners; /** * Logs an unknown component */ log(type: string, id: string, context?: string): void; /** * Gets all logged unknown components */ getLogs(): UnknownComponentLog[]; /** * Gets unique unknown component types */ getUniqueTypes(): string[]; /** * Clears all logs */ clear(): void; /** * Adds a listener for new unknown component logs */ addListener(listener: (log: UnknownComponentLog) => void): () => void; } /** * Global unknown component logger instance */ export declare const unknownComponentLogger: UnknownComponentLogger; /** * Gets suggestions for unknown component types */ export declare function getUnknownComponentSuggestions(type: string): string[]; /** * Available component types for reference */ export declare const AVAILABLE_COMPONENT_TYPES: readonly ["container", "card", "button", "input", "textarea", "select", "checkbox", "radio", "switch", "slider", "table", "list", "image", "text", "heading", "badge", "avatar", "alert", "dialog", "tabs", "accordion", "form", "separator"]; export type AvailableComponentType = typeof AVAILABLE_COMPONENT_TYPES[number]; export {}; //# sourceMappingURL=error-handling.d.ts.map