/** * ErrorDisplay component * * Displays error messages with icons and actionable options. */ export interface ErrorDisplayProps { error: string; type?: 'not-found' | 'network' | 'cors' | 'general' | 'no-wisp-records'; onRetry?: () => void; onBack?: () => void; showProxySuggestion?: boolean; } const errorIcons: Record, { icon: string; color: string }> = { 'not-found': { icon: '🔍', color: 'text-amber-500' }, 'network': { icon: '🌐', color: 'text-red-500' }, 'cors': { icon: '🔒', color: 'text-orange-500' }, 'general': { icon: '⚠️', color: 'text-gray-500' }, 'no-wisp-records': { icon: '📁', color: 'text-amber-500' }, }; const errorTitles: Record, string> = { 'not-found': 'Not Found', 'network': 'Network Error', 'cors': 'Connection Error', 'general': 'Error', 'no-wisp-records': 'No Site Found', }; export function ErrorDisplay({ error, type = 'general', onRetry, onBack, showProxySuggestion = false, }: ErrorDisplayProps) { const { icon, color } = errorIcons[type]; const title = errorTitles[type]; return (
{/* Icon */}
{icon}
{/* Title and Message */}

{title}

{error}

{/* Proxy suggestion for CORS errors */} {showProxySuggestion && (

Note: Some PDS servers don't support direct browser access. Consider using a CORS proxy for this operation.

)} {/* Action buttons */}
{onRetry && ( )} {onBack && ( )}
); } /** * Compact inline error display */ export interface InlineErrorProps { error: string; onDismiss?: () => void; } export function InlineError({ error, onDismiss }: InlineErrorProps) { return (
⚠️

{error}

{onDismiss && ( )}
); } /** * Error boundary fallback component */ export interface ErrorFallbackProps { error: Error; resetError?: () => void; } export function ErrorFallback({ error, resetError }: ErrorFallbackProps) { return (
💥

Something went wrong

An unexpected error occurred while loading the page.

{error.message && (

{error.message}

)} {resetError && (
)}
); }