// Error Boundary Component for Production "use client"; import { Component, ReactNode } from "react"; import { AlertTriangle } from "lucide-react"; import { Button } from "@/components/ui/button"; interface Props { children: ReactNode; fallback?: ReactNode; } interface State { hasError: boolean; error?: Error; } export class ErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { // Log to error reporting service in production console.error("Error Boundary caught:", error, errorInfo); } render() { if (this.state.hasError) { if (this.props.fallback) { return this.props.fallback; } return (

Something went wrong

{this.state.error?.message || "An unexpected error occurred"}

); } return this.props.children; } }