Files
Todo/app/error.tsx
Paul Bailey 12ce70e495 Implement comprehensive error handling
- Add try-catch blocks to all server actions with retry logic
- Implement exponential backoff retry mechanism for database operations
- Add input validation to all server actions
- Create ErrorBoundary component for React error handling
- Add page-level error handlers (error.tsx, global-error.tsx)
- Add route-specific error pages for list and item routes
- Enhance database connection with graceful error handling
- Add user-friendly error messages throughout the application
- Implement proper error logging for debugging

Task: 16. Implement error handling
Requirements: All (error handling is cross-cutting)
2025-12-01 21:18:57 +00:00

47 lines
1.6 KiB
TypeScript

'use client'
import { useEffect } from 'react'
import { AlertTriangle } from 'lucide-react'
export default function Error({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
useEffect(() => {
console.error('Page error:', error)
}, [error])
return (
<div className="min-h-screen flex items-center justify-center p-4 bg-gray-50">
<div className="max-w-md w-full bg-white rounded-lg shadow-lg p-6 sm:p-8">
<div className="flex items-center justify-center w-12 h-12 sm:w-16 sm:h-16 bg-red-100 rounded-full mx-auto mb-4">
<AlertTriangle className="w-6 h-6 sm:w-8 sm:h-8 text-red-600" />
</div>
<h2 className="text-xl sm:text-2xl font-bold text-gray-900 text-center mb-2">
Something went wrong
</h2>
<p className="text-sm sm:text-base text-gray-600 text-center mb-6">
{error.message || 'We encountered an unexpected error. Please try again.'}
</p>
<div className="flex flex-col sm:flex-row gap-3">
<button
onClick={reset}
className="flex-1 px-4 py-3 bg-blue-500 hover:bg-blue-600 active:bg-blue-700 text-white rounded-lg transition-colors font-medium text-sm sm:text-base tap-target"
>
Try Again
</button>
<button
onClick={() => window.location.href = '/'}
className="flex-1 px-4 py-3 bg-gray-200 hover:bg-gray-300 active:bg-gray-400 text-gray-700 rounded-lg transition-colors font-medium text-sm sm:text-base tap-target"
>
Go Home
</button>
</div>
</div>
</div>
)
}