'use client'; import React, { Component, ErrorInfo, ReactNode } from 'react'; import { AlertTriangle } from 'lucide-react'; interface Props { children: ReactNode; fallback?: ReactNode; } interface State { hasError: boolean; error: Error | null; } export class ErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false, error: null, }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error, }; } componentDidCatch(error: Error, errorInfo: ErrorInfo) { // Log error to console in development if (process.env.NODE_ENV === 'development') { console.error('ErrorBoundary caught an error:', error, errorInfo); } // In production, you could log to an error reporting service } render() { if (this.state.hasError) { if (this.props.fallback) { return this.props.fallback; } return (

Something went wrong

We encountered an unexpected error. Please try refreshing the page.

{process.env.NODE_ENV === 'development' && this.state.error && (
Error details (development only)
                  {this.state.error.toString()}
                
)}
); } return this.props.children; } }