From 1188550bf6727cb4ec59ad2984c579868afb7224 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Mon, 13 Apr 2026 22:59:38 -0400 Subject: [PATCH] feat: add dashboard-scoped error boundary Closes #1195. Adds `surfsense_web/app/dashboard/error.tsx` so unhandled errors in any dashboard route render inside the dashboard layout (sidebar/nav stay visible) instead of blowing out to the root-level error page. `reset()` now retries just the failed segment. Follows the same PostHog capture pattern as the root error.tsx and adds a secondary "Go to dashboard home" link for recovery when `reset()` doesn't help. --- surfsense_web/app/dashboard/error.tsx | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 surfsense_web/app/dashboard/error.tsx diff --git a/surfsense_web/app/dashboard/error.tsx b/surfsense_web/app/dashboard/error.tsx new file mode 100644 index 000000000..4d872a69f --- /dev/null +++ b/surfsense_web/app/dashboard/error.tsx @@ -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 ( +
+

Something went wrong

+

+ An error occurred in this section. Your dashboard is still available. +

+
+ + + Go to dashboard home + +
+
+ ); +}