"use client"; import { useEffect } from "react"; import { AlertTriangle, RefreshCw } from "lucide-react"; import { Button } from "@/components/ui/button"; import { reportClientError } from "@/components/logging/client-error-reporter"; import { useI18n } from "@/i18n/i18n-context"; /** * Route-segment error boundary for every page rendered under * `(dashboard)/layout.tsx`. Next.js mounts this component when a page * (or any of its children) throws during render, replacing the page * tree but keeping the surrounding sidebar / breadcrumb shell intact. * * The top-level `app/error.tsx` already catches truly catastrophic * failures; this dashboard-scoped boundary keeps the failure local so * users can navigate away via the sidebar without a full reload. */ export default function DashboardError({ error, reset, }: { error: Error & { digest?: string }; reset: () => void; }) { const { t } = useI18n(); useEffect(() => { // Surface the error to the browser console so engineers can copy the // stack trace; the digest field links the client-side message to the // server-side log line emitted by Next.js. console.error("Dashboard route error:", error); reportClientError({ event: "browser.error_boundary.dashboard", message: error.message, name: error.name, stack: error.stack, digest: error.digest, }); }, [error]); return (

{t("errors.dashboardTitle")}

{error.message || t("errors.dashboardFallback")}

{error.digest ? (

{t("errors.errorDigest")} {error.digest}

) : null}
); }