import React from 'react'; import PropTypes from 'prop-types'; import { Alert, Button } from 'antd'; import { ReloadOutlined } from '@ant-design/icons'; class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false, error: null, errorInfo: null }; } static getDerivedStateFromError(error) { return { hasError: true }; } componentDidCatch(error, errorInfo) { this.setState({ error, errorInfo }); // Log error to console in development if (process.env.NODE_ENV === 'development') { console.error('ErrorBoundary caught an error:', error, errorInfo); } } handleReload = () => { this.setState({ hasError: false, error: null, errorInfo: null }); window.location.reload(); }; render() { if (this.state.hasError) { return (

The application encountered an unexpected error.

{process.env.NODE_ENV === 'development' && this.state.error && (
Error Details (Development)
                      {this.state.error.toString()}
                      {this.state.errorInfo.componentStack}
                    
)}
} type="error" showIcon /> ); } return this.props.children; } } ErrorBoundary.propTypes = { children: PropTypes.node.isRequired }; export default ErrorBoundary;