mirror of
https://github.com/johndoe6345789/low-code-react-app-b.git
synced 2026-04-25 06:04:54 +00:00
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import { Alert, AlertTitle, AlertDescription } from "./components/ui/alert";
|
|
import { Button } from "./components/ui/button";
|
|
|
|
import { AlertTriangleIcon, RefreshCwIcon } from "lucide-react";
|
|
|
|
interface ErrorFallbackProps {
|
|
error: Error;
|
|
resetErrorBoundary: () => void;
|
|
}
|
|
|
|
export const ErrorFallback = ({ error, resetErrorBoundary }: ErrorFallbackProps) => {
|
|
console.error('ErrorFallback caught:', error);
|
|
|
|
if (import.meta.env.DEV) throw error;
|
|
|
|
return (
|
|
<div className="min-h-screen bg-background flex items-center justify-center p-4">
|
|
<div className="w-full max-w-md">
|
|
<Alert variant="destructive" className="mb-6">
|
|
<AlertTriangleIcon />
|
|
<AlertTitle>This spark has encountered a runtime error</AlertTitle>
|
|
<AlertDescription>
|
|
Something unexpected happened while running the application. The error details are shown below. Contact the spark author and let them know about this issue.
|
|
</AlertDescription>
|
|
</Alert>
|
|
|
|
<div className="bg-card border rounded-lg p-4 mb-6">
|
|
<h3 className="font-semibold text-sm text-muted-foreground mb-2">Error Details:</h3>
|
|
<pre className="text-xs text-destructive bg-muted/50 p-3 rounded border overflow-auto max-h-32">
|
|
{error.message}
|
|
</pre>
|
|
{error.stack && (
|
|
<pre className="text-xs text-muted-foreground bg-muted/50 p-3 rounded border overflow-auto max-h-48 mt-2">
|
|
{error.stack}
|
|
</pre>
|
|
)}
|
|
</div>
|
|
|
|
<Button
|
|
onClick={resetErrorBoundary}
|
|
className="w-full"
|
|
variant="outline"
|
|
>
|
|
<RefreshCwIcon />
|
|
Try Again
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|