"use client"; import React, { Component, ErrorInfo, ReactNode } from 'react'; interface Props { children: ReactNode; } interface State { hasError: boolean; error: Error | null; errorInfo: ErrorInfo | null; } class ErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false, error: null, errorInfo: null }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error, errorInfo: null }; } componentDidCatch(error: Error, errorInfo: ErrorInfo) { console.error("ErrorBoundary caught an error:", error, errorInfo); this.setState({ errorInfo }); } handleReload = () => { window.location.reload(); }; handleClearStorage = () => { try { localStorage.clear(); sessionStorage.clear(); window.location.reload(); } catch (e) { console.error("Failed to clear storage:", e); window.location.reload(); } }; render() { if (this.state.hasError) { return (

Something went wrong

An error occurred while rendering the application. This might be due to corrupted data or a temporary issue.

{process.env.NODE_ENV === 'development' && this.state.error && (
Error Details
                                    {this.state.error.toString()}
                                    {this.state.errorInfo?.componentStack}
                                
)}
); } return this.props.children; } } export default ErrorBoundary;