所有 129 个 error.tsx 客户端错误边界接入 useErrorReport Hook,客户端路由错误自动上报到 /api/client-error 端点,服务端通过 pino logger 统一记录。移除了 7 处 useEffect + console.error 调用。为无 props 的 error.tsx 补全 error 参数解构。
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
"use client"
|
|
|
|
import { BarChart3 } from "lucide-react"
|
|
import { useTranslations } from "next-intl"
|
|
|
|
import { EmptyState } from "@/shared/components/ui/empty-state"
|
|
import { useErrorReport } from "@/shared/hooks/use-error-report"
|
|
|
|
export default function GradePracticeError({
|
|
error,
|
|
reset,
|
|
}: {
|
|
error: Error & { digest?: string }
|
|
reset: () => void
|
|
}): React.ReactNode {
|
|
const t = useTranslations("practice")
|
|
useErrorReport(error)
|
|
|
|
return (
|
|
<div className="flex h-full flex-col space-y-8 p-8">
|
|
<div>
|
|
<h1 className="text-2xl font-bold tracking-tight">
|
|
{t("errors.pageErrorTitleGrade")}
|
|
</h1>
|
|
<p className="text-muted-foreground">{t("errors.pageErrorGrade")}</p>
|
|
</div>
|
|
{/* arbitrary-value: error icon fixed size */}
|
|
<EmptyState
|
|
icon={BarChart3}
|
|
title={t("errors.loadFailed")}
|
|
description={t("errors.loadFailedDescription")}
|
|
action={{
|
|
label: t("errors.retry"),
|
|
onClick: () => reset(),
|
|
}}
|
|
className="h-[360px] bg-card"
|
|
/>
|
|
</div>
|
|
)
|
|
}
|