"use client"; import { useEffect } from "react"; import { RefreshCw } from "lucide-react"; import { useT } from "@/components/I18n"; import { isStaleAction, reportStaleAction } from "@/components/StaleActionGuard"; import { reportCaughtError } from "@/lib/stale-action"; /** * PEP-324: the error boundary of every page. Before it a failed form action (most often a button of a * page opened before an update) left the person with Next's «Application error». An unknown action is * handed to StaleActionGuard (keep the text, say FORGE was updated, reload); any other error gets a * plain screen and is reported to «Ошибки из прода» from here: Next prints a caught error with the * console.error it took before ErrorReporter wrapped it, so nobody else would report it. */ export default function PageError({ error }: { error: Error & { digest?: string } }) { const t = useT(); const stale = isStaleAction(error); useEffect(() => { if (stale) reportStaleAction(); else reportCaughtError(error, window); }, [stale, error]); if (stale) return null; return (
{t("Страница не открылась из-за ошибки.")}
{t("Обновите страницу или вернитесь назад.")}