/** * Enhanced Error Handling System * * Provides comprehensive error classification, recovery mechanisms, * and standardized error handling patterns. */ export interface ErrorContext { component: string; duration?: number; metadata?: Record; operation: string; requestId?: string; retryCount?: number; sessionId?: string; timestamp: Date; userId?: string; } export interface RecoveryStrategy { backoffMs?: number; fallbackValue?: unknown; maxRetries?: number; timeoutMs?: number; type: 'circuit-breaker' | 'degradation' | 'fallback' | 'retry'; } export declare class BaseError extends Error { readonly code: string; readonly cause?: Error; readonly context: ErrorContext; readonly details?: Record; readonly docsLink?: string; readonly fixSuggestions?: string[]; readonly recovery?: RecoveryStrategy; readonly userMessage?: string; constructor(message: string, code: string, details?: Record, context?: Partial, recovery?: RecoveryStrategy, cause?: Error, userMessage?: string, fixSuggestions?: string[], docsLink?: string); } export declare class ConfigurationError extends BaseError { constructor(message: string, details?: Record, context?: Partial, userMessage?: string, fixSuggestions?: string[], docsLink?: string); } export declare class ExecutionError extends BaseError { constructor(message: string, details?: Record, context?: Partial, recovery?: RecoveryStrategy, userMessage?: string, fixSuggestions?: string[], docsLink?: string); } export declare class NetworkError extends BaseError { constructor(message: string, details?: Record, context?: Partial, recovery?: RecoveryStrategy, userMessage?: string, fixSuggestions?: string[], docsLink?: string); } export declare class ProviderError extends BaseError { constructor(message: string, details?: Record, context?: Partial, recovery?: RecoveryStrategy, userMessage?: string, fixSuggestions?: string[], docsLink?: string); } export declare class ResourceError extends BaseError { constructor(message: string, details?: Record, context?: Partial, recovery?: RecoveryStrategy, userMessage?: string, fixSuggestions?: string[], docsLink?: string); } export declare class SecurityError extends BaseError { constructor(message: string, details?: Record, context?: Partial, userMessage?: string, fixSuggestions?: string[], docsLink?: string); } export declare class SessionError extends BaseError { constructor(message: string, details?: Record, context?: Partial, userMessage?: string, fixSuggestions?: string[], docsLink?: string); } export declare class TimeoutError extends BaseError { constructor(message: string, details?: Record, context?: Partial, recovery?: RecoveryStrategy, userMessage?: string, fixSuggestions?: string[], docsLink?: string); } export declare class ValidationError extends BaseError { constructor(message: string, details?: Record, context?: Partial, userMessage?: string, fixSuggestions?: string[], docsLink?: string); } /** * Circuit Breaker State */ export type CircuitState = 'closed' | 'half-open' | 'open'; /** * Circuit Breaker for external service calls */ export declare class CircuitBreaker { private readonly failureThreshold; private readonly recoveryTimeoutMs; private failureCount; private nextAttemptTime; private state; constructor(failureThreshold?: number, recoveryTimeoutMs?: number); /** * Execute operation with circuit breaker protection */ execute(operation: () => Promise, context?: Partial): Promise; getFailureCount(): number; getState(): CircuitState; private onFailure; private onSuccess; } /** * Retry utility with exponential backoff */ export declare function withRetry(operation: () => Promise, options: { backoffFactor?: number; baseDelayMs?: number; context?: Partial; maxDelayMs?: number; maxRetries?: number; retryCondition?: (error: Error) => boolean; }): Promise; /** * Safe async operation wrapper */ export declare function safeAsync(operation: () => Promise, fallback?: T, context?: Partial): Promise; /** * Safe synchronous operation wrapper */ export declare function safeSync(operation: () => T, fallback?: T, context?: Partial): T | undefined; /** * Create error context helper */ export declare function createErrorContext(component: string, operation: string, additionalContext?: Record): Partial; /** * Format error for display with enhanced context */ export declare function formatError(error: Error): string; export { formatErrorMessage } from './error-utils.js'; /** * Check if error is retriable (enhanced version) */ export declare function isRetriableError(error: Error): boolean; /** * Check if error should trigger circuit breaker */ export declare function isCircuitBreakerError(error: Error): boolean; /** * Get or create circuit breaker for a service */ export declare function getCircuitBreaker(serviceName: string): CircuitBreaker; /** * Execute operation with circuit breaker protection */ export declare function withCircuitBreaker(serviceName: string, operation: () => Promise, context?: Partial): Promise; //# sourceMappingURL=error-handler.d.ts.map