lumina/ui/views/graph/error-boundary.js
2025-11-29 23:13:05 +03:00

73 lines
2.8 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from 'react'
class ThreeGalaxyErrorBoundary extends React.Component {
constructor(props) {
super(props)
this.state = {hasError: false, error: null, errorInfo: null}
}
static getDerivedStateFromError(error) {
return {hasError: true, error}
}
componentDidCatch(error, errorInfo) {
console.error('3D Galaxy Error:', error, errorInfo)
this.setState({
error: typeof error === 'string' ? new Error(error) : error,
errorInfo
})
}
render() {
if (this.state.hasError) {
return (
<div className="three-galaxy-error">
<div className="error-content">
<h2>⚠️ 3D Visualization Error</h2>
<p>Unable to render 3D visualization. This might be due to:</p>
<ul>
<li>WebGL not supported or disabled in your browser</li>
<li>GPU acceleration disabled</li>
<li>Outdated graphics drivers</li>
<li>Browser compatibility issues</li>
</ul>
<div className="error-actions">
<button
onClick={() => {
this.setState({hasError: false, error: null, errorInfo: null})
window.location.reload()
}}
className="error-button"
>
Reload Page
</button>
<button
onClick={() => {
this.setState({hasError: false, error: null, errorInfo: null})
}}
className="error-button secondary"
>
Try Again
</button>
</div>
{(typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'development') && this.state.error && (
<details className="error-details">
<summary>Error Details (Development Only)</summary>
<pre>{this.state.error.toString()}</pre>
{this.state.errorInfo && (
<pre>{this.state.errorInfo.componentStack}</pre>
)}
</details>
)}
</div>
</div>
)
}
return this.props.children
}
}
export default ThreeGalaxyErrorBoundary