From e91d88e9ec0a67621a3940ab7e19451846a6a1b4 Mon Sep 17 00:00:00 2001 From: Maher El Gamil Date: Thu, 28 May 2026 05:08:17 +0300 Subject: [PATCH] fix(error-page): render gracefully when panel prop is missing The error page assumed `panel` was always provided, but a 500 thrown outside the panel middleware stack (or before `RenderMonorailErrorPages` injects the panel data) arrives with `panel === undefined`. The page then crashed at `panel.translations`, masking the original server error with a React render error. Make `panel` optional, fall back to safe defaults, and render a standalone centered layout when the panel shell can't be used. --- resources/js/pages/error.tsx | 43 ++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/resources/js/pages/error.tsx b/resources/js/pages/error.tsx index 9b32769..8297595 100644 --- a/resources/js/pages/error.tsx +++ b/resources/js/pages/error.tsx @@ -19,7 +19,7 @@ type PanelProp = { }; type Props = { - panel: PanelProp; + panel?: PanelProp; status: number; title: string; message: string; @@ -32,24 +32,33 @@ function iconFor(status: number) { } export default function ErrorPage({ panel, status, title, message }: Props) { - const __ = create__(panel.translations ?? {}); + const __ = create__(panel?.translations ?? {}); const Icon = iconFor(status); + const homeHref = panel?.path ? `/${panel.path}` : '/'; - return ( - -
-
- -
-

{status}

-

{title}

-

{message}

-
- -
+ const body = ( +
+
+
- +

{status}

+

{title}

+

{message}

+
+ +
+
); + + if (!panel) { + return ( +
+ {body} +
+ ); + } + + return {body}; }