Spaces:
Running
Running
Download bioai-platform/frontend/src/components/ErrorBoundary.tsx from Samad14/bio-nexus-api: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/spaces/Samad14/bio-nexus-api/resolve/main/bioai-platform/frontend/src/components/ErrorBoundary.tsx
- Command line
-
hf download hf://spaces/Samad14/bio-nexus-api/bioai-platform/frontend/src/components/ErrorBoundary.tsx
-
curl -L -o ErrorBoundary.tsx https://huggingface.co/spaces/Samad14/bio-nexus-api/resolve/main/bioai-platform/frontend/src/components/ErrorBoundary.tsx
1.43 kB
| 'use client'; | |
| import { Component } from 'react'; | |
| import { WarningCircle as AlertCircle } from '@phosphor-icons/react'; | |
| interface Props { | |
| children: React.ReactNode; | |
| } | |
| interface State { | |
| hasError: boolean; | |
| error: Error | null; | |
| } | |
| export class ErrorBoundary extends Component<Props, State> { | |
| constructor(props: Props) { | |
| super(props); | |
| this.state = { hasError: false, error: null }; | |
| } | |
| static getDerivedStateFromError(error: Error): State { | |
| return { hasError: true, error }; | |
| } | |
| componentDidCatch(error: Error, info: React.ErrorInfo) { | |
| console.error('[ErrorBoundary]', error, info.componentStack); | |
| } | |
| render() { | |
| if (this.state.hasError) { | |
| return ( | |
| <div className="flex items-center justify-center py-20 px-4"> | |
| <div className="glass-card p-12 text-center max-w-md"> | |
| <AlertCircle className="w-12 h-12 text-error mx-auto mb-4" /> | |
| <h2 className="text-lg font-semibold text-text-primary mb-2">Something went wrong</h2> | |
| <p className="text-sm text-text-secondary mb-6"> | |
| {this.state.error?.message || 'An unexpected error occurred'} | |
| </p> | |
| <button | |
| onClick={() => window.location.reload()} | |
| className="btn-primary px-6 py-2.5 text-sm" | |
| > | |
| Reload page | |
| </button> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| return this.props.children; | |
| } | |
| } | |