import React from 'react'; class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false, error: null, errorInfo: null }; } static getDerivedStateFromError(error) { // Update state so the next render will show the fallback UI return { hasError: true }; } componentDidCatch(error, errorInfo) { // Log the error details console.error('ErrorBoundary caught an error:', error, errorInfo); // You can also log the error to an error reporting service here this.setState({ error: error, errorInfo: errorInfo }); } render() { if (this.state.hasError) { // Fallback UI return (

Something went wrong

An error occurred while loading the chat interface.

{this.props.showDetails && this.state.error && (
Error Details
                    {this.state.error.toString()}
                    {this.state.errorInfo && this.state.errorInfo.componentStack}
                  
)}
); } return this.props.children; } } export default ErrorBoundary;