Spaces:
Runtime error
Runtime error
Download Frontend/src/components/ErrorBoundary.jsx from jinksQspider/ExamCraftAI: direct link, hf CLI and curl.
- Browser
- Download file 2.49 kB
-
https://huggingface.co/spaces/jinksQspider/ExamCraftAI/resolve/main/Frontend/src/components/ErrorBoundary.jsx
- Command line
-
hf download hf://spaces/jinksQspider/ExamCraftAI/Frontend/src/components/ErrorBoundary.jsx
-
curl -L -o ErrorBoundary.jsx https://huggingface.co/spaces/jinksQspider/ExamCraftAI/resolve/main/Frontend/src/components/ErrorBoundary.jsx
2.49 kB
| import React from "react"; | |
| import { AlertTriangle, RotateCcw } from "lucide-react"; | |
| import { Button } from "./ui/Button"; | |
| class ErrorBoundary extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { hasError: false, error: null }; | |
| } | |
| static getDerivedStateFromError(error) { | |
| return { hasError: true, error }; | |
| } | |
| componentDidCatch(error, errorInfo) { | |
| console.error("ErrorBoundary caught an error:", error, errorInfo); | |
| } | |
| render() { | |
| if (this.state.hasError) { | |
| return ( | |
| <div className="flex flex-col items-center justify-center min-h-[400px] p-6 text-center space-y-6 bg-card border border-border rounded-2xl shadow-sm"> | |
| <div className="bg-destructive/10 p-4 rounded-full text-destructive animate-pulse"> | |
| <AlertTriangle size={48} /> | |
| </div> | |
| <div className="max-w-md space-y-2"> | |
| <h2 className="text-2xl font-bold tracking-tight">Something went wrong</h2> | |
| <p className="text-muted-foreground"> | |
| An unexpected error occurred in this section of the application. | |
| If this persists, please try refreshing the page. | |
| </p> | |
| </div> | |
| {this.state.error && ( | |
| <div className="bg-muted p-3 rounded-lg text-xs font-mono text-left max-w-full overflow-auto border border-border opacity-70"> | |
| {this.state.error.toString()} | |
| </div> | |
| )} | |
| <div className="flex gap-4"> | |
| <Button | |
| variant="primary" | |
| onClick={() => window.location.reload()} | |
| className="flex items-center gap-2" | |
| > | |
| <RotateCcw size={16} /> | |
| Reload Page | |
| </Button> | |
| <Button | |
| variant="ghost" | |
| onClick={() => this.setState({ hasError: false })} | |
| > | |
| Try Recovery | |
| </Button> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| return this.props.children; | |
| } | |
| } | |
| export default ErrorBoundary; | |