"use client"; import React, { Component, type ReactNode } from "react"; import { logger } from "../../../lib/logger"; interface ErrorBoundaryProps { children: ReactNode; } interface ErrorBoundaryState { hasError: boolean; error: Error | null; } class ErrorBoundary extends Component { constructor(props: ErrorBoundaryProps) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error: Error): ErrorBoundaryState { // Update state so the next render will show the fallback UI return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { // Log the error to an error reporting service logger.error("ErrorBoundary caught an error:", error, errorInfo); } render() { if (this.state.hasError) { // Fallback UI using design tokens return (

Something went wrong

We're sorry, but something unexpected happened.

); } return this.props.children; } } export default ErrorBoundary;