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;