"use client"; import React, { Component, ReactNode } from "react"; interface Props { children: ReactNode; } interface State { hasError: boolean; error: Error | null; } /** * Global error boundary for catching application-level errors. * Provides a fallback UI when critical errors occur in production. */ export class GlobalErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { console.error("[GlobalErrorBoundary] Application error:", error); console.error( "[GlobalErrorBoundary] Component stack:", errorInfo.componentStack ); } private handleReload = () => { window.location.reload(); }; render() { if (this.state.hasError) { return (

Something went wrong

An unexpected error occurred. Please try reloading the page.

{this.state.error && (

{this.state.error.message}

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