"use client"; import * as React from "react"; interface ErrorBoundaryState { hasError: boolean; error: Error | null; errorInfo: React.ErrorInfo | null; } interface ErrorBoundaryProps { children: React.ReactNode; fallback?: React.ReactNode; } export class ErrorBoundary extends React.Component< ErrorBoundaryProps, ErrorBoundaryState > { constructor(props: ErrorBoundaryProps) { super(props); this.state = { hasError: false, error: null, errorInfo: null }; } static getDerivedStateFromError(error: Error) { return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { this.setState({ errorInfo }); console.error("ErrorBoundary caught:", error, errorInfo); } render() { if (this.state.hasError) { return (

Something went wrong

            {this.state.error?.toString()}
          
Component Stack
              {this.state.errorInfo?.componentStack}
            
); } return this.props.children; } }