tensorwall / frontend /src /app /error.tsx
data-llm-hub's picture
TensorWall Demo for HuggingFace Spaces
f3bcb28
Raw History Blame Contribute Delete
3.12 kB
'use client';
import { useEffect } from 'react';
import { AlertTriangle, RefreshCw, Home } from 'lucide-react';
export default function Error({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
useEffect(() => {
// Log the error to an error reporting service
console.error('Application error:', error);
}, [error]);
return (
<div className="min-h-screen bg-gradient-to-br from-red-50 to-orange-50 flex items-center justify-center p-4">
<div className="max-w-2xl w-full">
{/* Error Icon */}
<div className="flex justify-center mb-6">
<div className="bg-red-100 p-6 rounded-full">
<AlertTriangle className="w-16 h-16 text-red-600" />
</div>
</div>
{/* Error Message */}
<div className="bg-white rounded-2xl shadow-xl p-8 text-center">
<h1 className="text-3xl font-bold text-gray-900 mb-4">
Oops! Something went wrong
</h1>
<p className="text-gray-600 mb-6">
We&apos;re sorry, something went wrong. Our team has been notified and is working on the issue.
</p>
{/* Error Details (Only in development) */}
{process.env.NODE_ENV === 'development' && (
<div className="mb-6 p-4 bg-red-50 rounded-lg text-left">
<p className="text-sm font-semibold text-red-800 mb-2">Error details (dev only):</p>
<code className="text-xs text-red-700 block whitespace-pre-wrap break-all">
{error.message}
</code>
{error.digest && (
<p className="text-xs text-red-600 mt-2">
Error ID: {error.digest}
</p>
)}
</div>
)}
{/* Actions */}
<div className="flex flex-col sm:flex-row gap-4 justify-center">
<button
onClick={reset}
className="flex items-center justify-center gap-2 px-6 py-3 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors font-medium"
>
<RefreshCw className="w-5 h-5" />
Try again
</button>
<a
href="/"
className="flex items-center justify-center gap-2 px-6 py-3 border-2 border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition-colors font-medium"
>
<Home className="w-5 h-5" />
Back to home
</a>
</div>
{/* Help Text */}
<div className="mt-8 pt-6 border-t border-gray-200">
<p className="text-sm text-gray-500">
If the problem persists, please contact technical support with the error ID above.
</p>
</div>
</div>
{/* Additional Info */}
<div className="mt-6 text-center">
<p className="text-sm text-gray-600">
Need help? <a href="mailto:support@example.com" className="text-blue-600 hover:underline">Contact support</a>
</p>
</div>
</div>
</div>
);
}