'use client';
import { ErrorBoundary as ReactErrorBoundary } from 'react-error-boundary';
import { AlertCircle } from 'lucide-react';
import { Button } from '@/components/ui/button';
interface ErrorFallbackProps {
error: Error;
resetErrorBoundary: () => void;
}
function ErrorFallback({ error, resetErrorBoundary }: ErrorFallbackProps) {
return (
Something went wrong
{error.message || 'An unexpected error occurred'}
);
}
interface ErrorBoundaryProps {
children: React.ReactNode;
}
export function ErrorBoundary({ children }: ErrorBoundaryProps) {
return (
{
// Optional: Reset application state here
// For now, we'll just reload the current page
window.location.reload();
}}
onError={(error, errorInfo) => {
// Log error to console in development
console.error('Error caught by boundary:', error, errorInfo);
// In production, you could send this to an error tracking service
// like Sentry, LogRocket, etc.
}}
>
{children}
);
}