From 1ba61f691ee30ea1c17e4e0bb88a11df6439248f Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 11 Jun 2025 18:26:35 +0200 Subject: [PATCH] Add error detail on PageError Signed-off-by: Bryan Frimin Signed-off-by: Sacha Al Himdani --- apps/console2/src/components/PageError.tsx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/console2/src/components/PageError.tsx b/apps/console2/src/components/PageError.tsx index 14efa64be..893486e74 100644 --- a/apps/console2/src/components/PageError.tsx +++ b/apps/console2/src/components/PageError.tsx @@ -7,21 +7,27 @@ const classNames = { wrapper: "py-10 text-center space-y-2 ", title: "text-2xl flex gap-2 font-semibold items-center justify-center", description: "text-base text-txt-tertiary", + detail: + "text-sm text-txt-tertiary font-mono text-start border border-border-low p-2 rounded bg-level-1 mt-2", }; type Props = { - resetErrorBoundary: () => void; + resetErrorBoundary?: () => void; + error?: string; }; -export function PageError({ resetErrorBoundary }: Props) { - const error = useRouteError(); +export function PageError({ resetErrorBoundary, error: propsError }: Props) { + const error = useRouteError() ?? propsError; const { __ } = useTranslate(); const location = useLocation(); const baseLocation = useRef(location); // Reset error boundary on page change useEffect(() => { - if (location.pathname !== baseLocation.current.pathname) { + if ( + location.pathname !== baseLocation.current.pathname && + resetErrorBoundary + ) { resetErrorBoundary(); } }, [location, resetErrorBoundary]); @@ -43,7 +49,12 @@ export function PageError({ resetErrorBoundary }: Props) { return (

{__("Unexpected error :(")}

-

{error.toString()}

+
+ + {__("Something went wrong")} + +

{error.toString()}

+
); }