From 0c068dba3d69f5899864572f70d606a0d533725b Mon Sep 17 00:00:00 2001 From: Beshr Islam Bouli Date: Fri, 11 Oct 2024 17:34:06 -0400 Subject: [PATCH 1/4] test --- frontend2/src/views/ErrorBoundary.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend2/src/views/ErrorBoundary.tsx b/frontend2/src/views/ErrorBoundary.tsx index e2a816327..6affecd8d 100644 --- a/frontend2/src/views/ErrorBoundary.tsx +++ b/frontend2/src/views/ErrorBoundary.tsx @@ -11,7 +11,7 @@ const ErrorBoundary: React.FC = () => { Oops, something went wrong.

Please reach out on Discord or to battlecode@mit.edu with the - following error message: + following error message: Beshr

{error.message} From e6c01af31915940a6af06fa6ed0384438cbe01b8 Mon Sep 17 00:00:00 2001 From: Beshr Islam Bouli Date: Sat, 2 Nov 2024 13:32:07 -0400 Subject: [PATCH 2/4] Added Error boundary --- frontend2/src/views/ErrorBoundary.tsx | 40 ++++++++++++++++++--------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/frontend2/src/views/ErrorBoundary.tsx b/frontend2/src/views/ErrorBoundary.tsx index 6affecd8d..c852b46f2 100644 --- a/frontend2/src/views/ErrorBoundary.tsx +++ b/frontend2/src/views/ErrorBoundary.tsx @@ -1,26 +1,40 @@ import React from "react"; -import { useRouteError } from "react-router-dom"; +import { useRouteError, useNavigate } from "react-router-dom"; import { PageTitle } from "../components/elements/BattlecodeStyle"; +import { DEFAULT_EPISODE } from "../utils/constants"; const ErrorBoundary: React.FC = () => { const error = useRouteError(); + const navigate = useNavigate(); // Initialize useNavigate - if (error instanceof Error) { - return ( -
+ const handleGoHome = (): void => { + navigate(`/${DEFAULT_EPISODE}/home`); // Navigate to home + }; + + return ( +
+
Oops, something went wrong. -

+

Please reach out on Discord or to battlecode@mit.edu with the - following error message: Beshr + following error message:

- - {error.message} - + {error instanceof Error ? ( + + {error.message} + + ) : ( + An unknown error occurred. + )} +
- ); - } - - return

Oops, something went wrong.

; +
+ ); }; export default ErrorBoundary; From 5661dc378e2f831e951216cf1420f63f9654e712 Mon Sep 17 00:00:00 2001 From: Beshr Islam Bouli Date: Sat, 9 Nov 2024 13:23:30 -0500 Subject: [PATCH 3/4] Fixed Error boundry following serena comments --- frontend2/src/views/ErrorBoundary.tsx | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/frontend2/src/views/ErrorBoundary.tsx b/frontend2/src/views/ErrorBoundary.tsx index c852b46f2..a93deb046 100644 --- a/frontend2/src/views/ErrorBoundary.tsx +++ b/frontend2/src/views/ErrorBoundary.tsx @@ -1,15 +1,11 @@ import React from "react"; -import { useRouteError, useNavigate } from "react-router-dom"; +import { useRouteError, Link } from "react-router-dom"; import { PageTitle } from "../components/elements/BattlecodeStyle"; -import { DEFAULT_EPISODE } from "../utils/constants"; +import { useEpisodeId } from "../contexts/EpisodeContext"; const ErrorBoundary: React.FC = () => { const error = useRouteError(); - const navigate = useNavigate(); // Initialize useNavigate - - const handleGoHome = (): void => { - navigate(`/${DEFAULT_EPISODE}/home`); // Navigate to home - }; + const { episodeId } = useEpisodeId(); return (
@@ -26,12 +22,9 @@ const ErrorBoundary: React.FC = () => { ) : ( An unknown error occurred. )} - + + Back to home +
); From 34d637c50fcbe1c48233ff5ae4b0996b7cc110b9 Mon Sep 17 00:00:00 2001 From: Beshr Islam Bouli Date: Sat, 9 Nov 2024 13:31:14 -0500 Subject: [PATCH 4/4] Used div to make it nicer and ran npm run format --- frontend2/src/views/ErrorBoundary.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend2/src/views/ErrorBoundary.tsx b/frontend2/src/views/ErrorBoundary.tsx index a93deb046..7fc964499 100644 --- a/frontend2/src/views/ErrorBoundary.tsx +++ b/frontend2/src/views/ErrorBoundary.tsx @@ -9,21 +9,25 @@ const ErrorBoundary: React.FC = () => { return (
-
+
Oops, something went wrong.

Please reach out on Discord or to battlecode@mit.edu with the following error message:

{error instanceof Error ? ( - + {error.message} ) : ( - An unknown error occurred. + + An unknown error occurred. + )} - Back to home +
+ Go to Home +