import { AppError } from './errorTypes'; /** * Context information for generating error messages */ export interface ErrorMessageContext { /** What the user was trying to do (e.g., "save your changes") */ userAction?: string; /** Resource being accessed (e.g., "dashboard", "user profile") */ resource?: string; /** Feature name (e.g., "Reports", "Settings") */ feature?: string; /** Additional context metadata */ metadata?: Record; } /** * Structured error message for UI rendering */ export interface StructuredErrorMessage { /** Main error title for display */ title: string; /** Detailed description explaining what went wrong */ description: string; /** Suggested user actions to recover */ suggestions: string[]; /** Technical details (development only) */ technicalDetails?: string; /** Whether the error is recoverable */ recoverable: boolean; /** Suggested wait time before retry (ms) */ retryAfter?: number; } /** * Toast notification message */ export interface ToastMessage { /** Short message for toast display */ message: string; /** Toast type for styling */ type: 'info' | 'warning' | 'error' | 'success'; /** Auto-dismiss duration in ms (undefined = manual dismiss) */ duration?: number; } /** * Generate a structured error message based on error and context * * @param error - The normalized application error * @param context - Optional context about what the user was doing * @returns Structured error message for UI rendering * * @example * ```tsx * const message = getStructuredErrorMessage(error, { * userAction: 'save your document', * feature: 'Documents' * }); * * return ( * * ); * ``` */ export declare function getStructuredErrorMessage(error: AppError, context?: ErrorMessageContext): StructuredErrorMessage; /** * Get a short toast message for the error * * @param error - The normalized application error * @param context - Optional context * @returns String suitable for toast notification */ export declare function getToastMessage(error: AppError, context?: ErrorMessageContext): string; /** * Get a structured toast notification * * @param error - The normalized application error * @param context - Optional context * @returns Toast message with type and duration */ export declare function getToastNotification(error: AppError, context?: ErrorMessageContext): ToastMessage; /** * Get a recovery hint for the error * * @param error - The normalized application error * @returns Recovery hint string or null if not recoverable */ export declare function getRecoveryHint(error: AppError): string | null; /** * Convert HTTP status code to user-friendly message * * @param status - HTTP status code * @returns User-friendly message describing the status */ export declare function httpStatusToMessage(status: number): string; /** * Create a contextual error message with action and resource * * @param error - The normalized application error * @param action - Action being performed (e.g., "load", "save", "delete") * @param resource - Resource being acted upon (optional) * @returns Contextual message string * * @example * ```tsx * const message = createContextualMessage(error, 'save', 'document'); * // => "Unable to connect while saving document. Check your internet connection." * ``` */ export declare function createContextualMessage(error: AppError, action: string, resource?: string): string; /** * Get the appropriate action text for error recovery buttons * * @param error - The normalized application error * @returns Object with primary and secondary action labels */ export declare function getRecoveryActions(error: AppError): { primaryAction: string; primaryLabel: string; secondaryAction?: string; secondaryLabel?: string; }; /** * Format an error for logging (includes technical details) * * @param error - The normalized application error * @param context - Optional context * @returns Formatted string for logging */ export declare function formatErrorForLogging(error: AppError, context?: ErrorMessageContext): string; /** * Check if an error message should be shown to the user * * Some errors (like cancelled requests or background sync errors) * should be handled silently. * * @param error - The normalized application error * @returns Whether to display the error to the user */ export declare function shouldShowError(error: AppError): boolean;