import React from 'react' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' interface GraphErrorBoundaryState { hasError: boolean error?: Error errorInfo?: React.ErrorInfo } interface GraphErrorBoundaryProps { children: React.ReactNode fallback?: React.ReactNode } export class GraphErrorBoundary extends React.Component { constructor(props: GraphErrorBoundaryProps) { super(props) this.state = { hasError: false } } static getDerivedStateFromError(error: Error): GraphErrorBoundaryState { return { hasError: true, error } } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { console.error('🔥 Graph Error Boundary caught an error:', error, errorInfo) // Log specific Cytoscape.js errors for debugging if (error.message.includes('cytoscape') || error.message.includes('container')) { console.error('🎯 Cytoscape.js specific error detected:', { message: error.message, stack: error.stack, componentStack: errorInfo.componentStack }) } this.setState({ error, errorInfo }) } handleRetry = () => { this.setState({ hasError: false, error: undefined, errorInfo: undefined }) } render() { if (this.state.hasError) { if (this.props.fallback) { return this.props.fallback } return ( ⚠️ Graph Visualization Error

The graph visualization encountered an error and couldn't render properly.

This might be due to invalid data or a rendering issue. Please try refreshing the page or contact support if the problem persists.

{this.state.error && (
Error: {this.state.error.message}
)}
) } return this.props.children } }