/** * ThreadTS Universal - Advanced Error Handling and Recovery System * Comprehensive error detection, classification, and recovery mechanisms */ export interface ErrorContext { operation: string; timestamp: number; platform: string; workerCount: number; memoryUsage?: number; stackTrace?: string; additionalData?: Record; } export interface ErrorMetrics { errorCount: number; errorRate: number; lastErrorTime: number; commonErrors: Map; criticalErrors: number; recoverySuccessRate: number; } export interface RecoveryStrategy { name: string; condition: (error: Error, context: ErrorContext) => boolean; action: (error: Error, context: ErrorContext) => Promise; priority: number; } export declare class ErrorHandler { private errors; private recoveryStrategies; private circuitBreakerStates; private retryPolicies; constructor(); /** * Initializes default recovery strategies */ private initializeDefaultStrategies; /** * Initializes default retry policies for different operations */ private initializeDefaultRetryPolicies; /** * Handles an error with automatic recovery attempts */ handleError(error: Error, context: ErrorContext): Promise; /** * Records an error for metrics and analysis */ private recordError; /** * Checks if circuit breaker is open for an operation */ private isCircuitBreakerOpen; /** * Updates circuit breaker state */ private updateCircuitBreaker; /** * Records a successful recovery */ private recordRecoverySuccess; /** * Records a failed recovery */ private recordRecoveryFailure; /** * Adds a custom recovery strategy */ addRecoveryStrategy(strategy: RecoveryStrategy): void; /** * Sets retry policy for an operation */ setRetryPolicy(operation: string, policy: { maxRetries: number; backoffMs: number; multiplier: number; }): void; /** * Executes an operation with automatic retry and error handling */ executeWithRetry(operation: string, fn: () => Promise, context?: Partial): Promise; /** * Gets error metrics for analysis */ getErrorMetrics(): ErrorMetrics; /** * Calculates recovery success rate */ private calculateRecoverySuccessRate; /** * Helper methods for recovery strategies */ private clearInternalCaches; private reduceWorkerPoolSize; private adjustTimeouts; /** * Generates a comprehensive error report */ generateErrorReport(): string; /** * Resets all error data and states */ reset(): void; /** * Gets recent errors for debugging */ getRecentErrors(count?: number): Array<{ error: Error; context: ErrorContext; }>; } export declare const errorHandler: ErrorHandler; //# sourceMappingURL=error-handler.d.ts.map