import { AvatarStreamError, ErrorCode } from './error'; import { Logger } from './logger'; /** * Result of an error recovery attempt */ export interface ErrorRecoveryResult { /** Whether recovery was successful */ recovered: boolean; /** Message describing the recovery attempt */ message: string; /** Original error that was being recovered from */ originalError: AvatarStreamError; } /** * Configuration for the error recovery manager */ export interface ErrorRecoveryConfig { /** Logger instance */ logger?: Logger; /** Maximum number of recovery attempts per error type */ maxRecoveryAttempts?: number; /** Whether to automatically attempt recovery */ autoRecover?: boolean; } /** * Type for error recovery strategies */ export type ErrorRecoveryStrategy = (error: AvatarStreamError, attemptCount: number) => Promise; /** * Manages error recovery strategies for different error types */ export declare class ErrorRecoveryManager { private logger; private maxRecoveryAttempts; private autoRecover; private recoveryStrategies; private recoveryAttempts; /** * Creates a new error recovery manager * @param config Configuration options */ constructor(config?: ErrorRecoveryConfig); /** * Registers a recovery strategy for a specific error code * @param errorCode The error code to handle * @param strategy The recovery strategy function * @returns This instance for chaining */ registerStrategy(errorCode: ErrorCode, strategy: ErrorRecoveryStrategy): this; /** * Handles an error by attempting recovery if a strategy exists * @param error The error to handle * @returns Promise resolving to the recovery result */ handleError(error: AvatarStreamError): Promise; /** * Resets the recovery attempt count for a specific error code * @param errorCode The error code to reset */ resetAttempts(errorCode: ErrorCode): void; /** * Resets all recovery attempt counts */ resetAllAttempts(): void; /** * Checks if automatic recovery is enabled * @returns True if automatic recovery is enabled */ isAutoRecoveryEnabled(): boolean; /** * Sets whether automatic recovery is enabled * @param enabled Whether to enable automatic recovery */ setAutoRecovery(enabled: boolean): void; }