- Add global-error.tsx at app root (inline styles, wraps html/body) - Add group-level error.tsx for (public) — catches all unguarded public routes - Add per-route error.tsx for high-traffic public segments: listings, listings/[id], du-an, du-an/[slug], khu-cong-nghiep, khu-cong-nghiep/[slug], agents, agents/[id], payment - Add auth/callback/error.tsx for OAuth callback failures - Commit coverage table to apps/web/docs/error-boundary-coverage.md Pre-existing API test failures unrelated to this change (broker-cert, update-listing-status, mcp.module) were already failing on master. Closes GOO-115 Co-Authored-By: Paperclip <noreply@paperclip.ing>
61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
'use client';
|
|
|
|
import { useEffect } from 'react';
|
|
|
|
export default function PublicError({
|
|
error,
|
|
reset,
|
|
}: {
|
|
error: Error & { digest?: string };
|
|
reset: () => void;
|
|
}) {
|
|
useEffect(() => {
|
|
console.error('Public page error:', error);
|
|
}, [error]);
|
|
|
|
return (
|
|
<div className="mx-auto max-w-7xl px-4 py-12">
|
|
<div className="flex min-h-[400px] flex-col items-center justify-center">
|
|
<div className="mx-auto max-w-md text-center">
|
|
<div className="mx-auto flex h-14 w-14 items-center justify-center rounded-full bg-destructive/10">
|
|
<svg
|
|
className="h-7 w-7 text-destructive"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
viewBox="0 0 24 24"
|
|
>
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
strokeWidth={2}
|
|
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"
|
|
/>
|
|
</svg>
|
|
</div>
|
|
<h2 className="mt-4 text-xl font-semibold">Không thể tải trang</h2>
|
|
<p className="mt-2 text-sm text-muted-foreground">
|
|
Đã xảy ra lỗi khi tải nội dung. Vui lòng thử lại.
|
|
</p>
|
|
{error.digest && (
|
|
<p className="mt-1 text-xs text-muted-foreground">Mã lỗi: {error.digest}</p>
|
|
)}
|
|
<div className="mt-6 flex justify-center gap-3">
|
|
<button
|
|
onClick={reset}
|
|
className="inline-flex h-9 items-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90"
|
|
>
|
|
Thử lại
|
|
</button>
|
|
<a
|
|
href="/"
|
|
className="inline-flex h-9 items-center rounded-md border border-input bg-background px-4 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground"
|
|
>
|
|
Về trang chủ
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|