/**
 * Comprehensive error handling and recovery system for DataPilot
 */
import type { ErrorContext, ErrorRecoveryStrategy } from '../core/types';
import { DataPilotError, ErrorSeverity, ErrorCategory } from '../core/types';
export { DataPilotError, ErrorSeverity, ErrorCategory, ActionableSuggestion } from '../core/types';
export type { ErrorContext, ErrorRecoveryStrategy } from '../core/types';
export interface ErrorHandlerConfig {
    maxRetries: number;
    retryDelayMs: number;
    enableRecovery: boolean;
    logErrors: boolean;
    abortOnCritical: boolean;
    memoryThresholdBytes: number;
    verboseMode: boolean;
    enhancedStackTraces: boolean;
    silentFailureDetection: boolean;
    performanceTracking: boolean;
    contextPreservation: boolean;
}
export interface ErrorStats {
    totalErrors: number;
    errorsByCategory: Record<ErrorCategory, number>;
    errorsBySeverity: Record<ErrorSeverity, number>;
    recoveredErrors: number;
    criticalErrors: number;
}
export declare class ErrorHandler {
    private config;
    private stats;
    private errorHistory;
    constructor(config?: Partial<ErrorHandlerConfig>);
    /**
     * Handle an error with recovery strategies
     */
    handleError<T>(error: DataPilotError, operation: () => Promise<T>, recoveryStrategy?: ErrorRecoveryStrategy): Promise<T | null>;
    /**
     * Handle synchronous errors
     */
    handleErrorSync<T>(error: DataPilotError, operation: () => T, fallbackValue?: T): T | null;
    /**
     * Validate configuration parameters
     */
    validateConfig(config: Record<string, unknown>, schema: Record<string, string>): DataPilotError[];
    /**
     * Check memory usage and throw error if threshold exceeded
     */
    checkMemoryUsage(context?: ErrorContext): void;
    /**
     * Create error with file corruption recovery suggestions
     */
    createFileCorruptionError(filePath: string, details: string): DataPilotError;
    /**
     * Create error for insufficient data
     */
    createInsufficientDataError(context: ErrorContext, minRequired: number, actual: number): DataPilotError;
    /**
     * Wrap operation with automatic error handling and enhanced context
     */
    wrapOperation<T>(operation: () => Promise<T>, operationName: string, context?: ErrorContext, recoveryStrategy?: ErrorRecoveryStrategy): Promise<T | null>;
    /**
     * Create enhanced error context with debugging information
     */
    createEnhancedContext(baseContext: Partial<ErrorContext>, operationName: string, additionalContext?: Record<string, unknown>): ErrorContext;
    /**
     * Detect silent failures in operation results
     */
    private detectSilentFailure;
    /**
     * Check for silent failure patterns in results
     */
    private checkForSilentFailurePatterns;
    /**
     * Get expected result description for operation
     */
    private getExpectedResultDescription;
    /**
     * Enable or disable verbose mode
     */
    setVerboseMode(enabled: boolean): void;
    /**
     * Get configuration for debugging
     */
    getConfig(): ErrorHandlerConfig;
    /**
     * Get error statistics
     */
    getStats(): ErrorStats;
    /**
     * Get error statistics (alias for compatibility)
     */
    getErrorStatistics(): {
        totalErrors: number;
        byCategory: Record<string, number>;
        bySeverity: Record<string, number>;
    };
    /**
     * Get recent errors
     */
    getRecentErrors(limit?: number): DataPilotError[];
    /**
     * Clear error history and reset stats
     */
    reset(): void;
    private recordError;
    private logError;
    private applyRecoveryStrategy;
    private retryOperation;
    private getDefaultRecoveryStrategy;
    private delay;
}
export declare const globalErrorHandler: ErrorHandler;
/**
 * Enhanced utility functions for common error scenarios
 */
export declare class ErrorUtils {
    /**
     * Handle CSV parsing errors with enhanced recovery and context
     */
    static handleParsingError(error: unknown, filePath: string, retryWithFallback: () => Promise<any>, operationContext?: Partial<ErrorContext>): Promise<any>;
    /**
     * Handle insufficient data scenarios
     */
    static handleInsufficientData<T>(actualCount: number, minimumRequired: number, context: ErrorContext, fallbackValue?: T): T;
    /**
     * Validate and clean data array
     */
    static validateDataArray(data: any[], context: ErrorContext): any[];
    /**
     * Safe numeric conversion with error handling
     */
    static safeToNumber(value: unknown, defaultValue?: number): number;
    /**
     * Safe property access with error handling
     */
    static safeGet<T>(obj: any, path: string, defaultValue?: T): T | undefined;
    /**
     * Wrap async operation with enhanced error context
     */
    static withEnhancedContext<T>(operation: () => Promise<T>, context: {
        operationName: string;
        section?: string;
        analyzer?: string;
        filePath?: string;
        additionalContext?: Record<string, unknown>;
    }): Promise<T>;
    /**
     * Create a contextual error with enhanced debugging information
     */
    static createContextualError(message: string, code: string, category: ErrorCategory, severity: ErrorSeverity, context: {
        operationName: string;
        section?: string;
        analyzer?: string;
        filePath?: string;
        dependencyContext?: Record<string, any>;
        additionalContext?: Record<string, unknown>;
    }): DataPilotError;
    /**
     * Check operation result and detect silent failures
     */
    static validateOperationResult<T>(result: T, expectedType: 'object' | 'array' | 'string' | 'number', operationName: string, context?: Partial<ErrorContext>): T;
}
//# sourceMappingURL=error-handler.d.ts.map