'use client'; import * as Sentry from '@sentry/nextjs'; import { Component, type ReactNode } from 'react'; interface Props { children: ReactNode; fallback?: ReactNode; } interface State { hasError: boolean; error?: Error; } export class ErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { // Log error to Sentry Sentry.captureException(error, { contexts: { react: { componentStack: errorInfo.componentStack, }, }, }); } render() { if (this.state.hasError) { // Render custom fallback UI if (this.props.fallback) { return this.props.fallback; } return (

Something went wrong

An error occurred while rendering this component.

{process.env.NODE_ENV === 'development' && this.state.error && (
                {this.state.error.message}
              
)}
); } return this.props.children; } }