/** * Error Handling Utilities * Provides convenient utilities for modules to integrate with the enhanced error handling system */ import { /* ErrorHandlingCenter, */ type ErrorContext } from 'rcc-errorhandling'; export declare function getErrorMessage(error: unknown): string; /** * Error handling options */ export interface ErrorHandlingOptions { severity?: 'low' | 'medium' | 'high' | 'critical'; category?: string; recovery?: string; additionalContext?: Record; suppressLogging?: boolean; } /** * Error context builder interface */ export interface ErrorContextBuilder { withSeverity(severity: 'low' | 'medium' | 'high' | 'critical'): ErrorContextBuilder; withCategory(category: string): ErrorContextBuilder; withRecovery(recovery: string): ErrorContextBuilder; withAdditionalContext(context: Record): ErrorContextBuilder; withSuppressedLogging(): ErrorContextBuilder; build(): ErrorContext; } /** * Context-aware error class */ export declare class ContextualError extends Error { readonly context: string; readonly moduleId: string; readonly severity: 'low' | 'medium' | 'high' | 'critical'; readonly category: string; readonly additionalContext?: Record; constructor(message: string, context: string, moduleId: string, options?: ErrorHandlingOptions); } /** * Error Handling Utilities class * Provides convenient methods for error handling across all modules */ export declare class ErrorHandlingUtils { private static registry; /** Detect sandbox/permission-denied style errors */ static detectSandboxPermissionError(err: unknown): { isSandbox: boolean; reason: string; }; /** * Initialize error handling utilities */ static initialize(): Promise; /** * Handle error with enhanced context */ static handleError(error: Error, context: string, moduleId: string, options?: ErrorHandlingOptions): Promise; /** * Create error context builder */ static createContextBuilder(error: Error, context: string, moduleId: string): ErrorContextBuilder; /** * Handle async function with error handling */ static withErrorHandling(fn: () => Promise, context: string, moduleId: string, options?: ErrorHandlingOptions): Promise; /** * Handle sync function with error handling */ static withSyncErrorHandling(fn: () => T, context: string, moduleId: string, options?: ErrorHandlingOptions): T; /** * Register custom error message */ static registerErrorMessage(code: string, message: string, severity: 'low' | 'medium' | 'high' | 'critical', category: string, description?: string, recovery?: string): void; /** * Register custom error handler */ static registerErrorHandler(errorCode: string, handler: (context: ErrorContext) => Promise, priority?: number, description?: string): void; /** * Create module-specific error handler */ static createModuleErrorHandler(moduleId: string): { /** * Handle error for this module */ handle: (error: Error, context: string, options?: ErrorHandlingOptions) => Promise; /** * Create contextual error for this module */ createError: (message: string, context: string, options?: ErrorHandlingOptions) => ContextualError; /** * Register error message for this module */ registerMessage: (code: string, message: string, severity: "low" | "medium" | "high" | "critical", category: string, description?: string, recovery?: string) => void; /** * Register error handler for this module */ registerHandler: (errorCode: string, handler: (context: ErrorContext) => Promise, priority?: number, description?: string) => void; /** * Wrap async function with error handling for this module */ wrapAsync: (fn: () => Promise, context: string, options?: ErrorHandlingOptions) => (() => Promise); /** * Wrap sync function with error handling for this module */ wrapSync: (fn: () => T, context: string, options?: ErrorHandlingOptions) => (() => T); }; /** * Log error with context */ private static logError; /** * Get log level based on severity */ private static getLogLevel; /** * Cleanup error handling utilities */ static destroy(): Promise; }