import React from 'react'; import { motion } from 'framer-motion'; import { Button } from '~/components/ui/Button'; import { classNames } from '~/utils/classNames'; import type { ServiceError } from '~/lib/utils/serviceErrorHandler'; interface ErrorStateProps { error?: ServiceError | string; title?: string; onRetry?: () => void; onDismiss?: () => void; retryLabel?: string; className?: string; showDetails?: boolean; } export function ErrorState({ error, title = 'Something went wrong', onRetry, onDismiss, retryLabel = 'Try again', className, showDetails = false, }: ErrorStateProps) { const errorMessage = typeof error === 'string' ? error : error?.message || 'An unknown error occurred'; const isServiceError = typeof error === 'object' && error !== null; return ( {title} {errorMessage} {showDetails && isServiceError && error.details && ( Technical details {JSON.stringify(error.details, null, 2)} )} {onRetry && ( {retryLabel} )} {onDismiss && ( Dismiss )} ); } interface ConnectionErrorProps { service: string; error: ServiceError | string; onRetryConnection: () => void; onClearError?: () => void; } export function ConnectionError({ service, error, onRetryConnection, onClearError }: ConnectionErrorProps) { return ( ); }
{errorMessage}
{JSON.stringify(error.details, null, 2)}