Merge pull request #1220 from mvanhorn/osc/1195-dashboard-error-boundary

feat: add dashboard-scoped error boundary
This commit is contained in:
Rohan Verma 2026-04-14 01:50:35 -07:00 committed by GitHub
commit 94dbbfa7e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,44 @@
"use client";
import Link from "next/link";
import { useEffect } from "react";
export default function DashboardError({
error,
reset,
}: {
error: globalThis.Error & { digest?: string };
reset: () => void;
}) {
useEffect(() => {
import("posthog-js")
.then(({ default: posthog }) => {
posthog.captureException(error);
})
.catch(() => {});
}, [error]);
return (
<div className="flex flex-1 flex-col items-center justify-center gap-4 p-8 text-center">
<h2 className="text-xl font-semibold">Something went wrong</h2>
<p className="text-muted-foreground max-w-md">
An error occurred in this section. Your dashboard is still available.
</p>
<div className="flex gap-2">
<button
type="button"
onClick={reset}
className="rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors"
>
Try again
</button>
<Link
href="/dashboard"
className="rounded-md border border-input bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground transition-colors"
>
Go to dashboard home
</Link>
</div>
</div>
);
}