From 91c3c0e9ffa379bbb71429d3be20ac123454ef8c Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 14 Jul 2025 08:00:18 -0400 Subject: [PATCH] fix/error-404 (#9626) --- app/scenes/Document/Shared.tsx | 11 ++++-- app/scenes/Document/components/DataLoader.tsx | 5 ++- app/scenes/Errors/ErrorUnknown.tsx | 36 +++++++++++++++++++ shared/i18n/locales/en_US/translation.json | 3 +- 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 app/scenes/Errors/ErrorUnknown.tsx diff --git a/app/scenes/Document/Shared.tsx b/app/scenes/Document/Shared.tsx index ade85c0ee9..59ba353828 100644 --- a/app/scenes/Document/Shared.tsx +++ b/app/scenes/Document/Shared.tsx @@ -26,9 +26,14 @@ import useCurrentUser from "~/hooks/useCurrentUser"; import { usePostLoginPath } from "~/hooks/useLastVisitedPath"; import useStores from "~/hooks/useStores"; import { client } from "~/utils/ApiClient"; -import { AuthorizationError, OfflineError } from "~/utils/errors"; +import { + AuthorizationError, + NotFoundError, + OfflineError, +} from "~/utils/errors"; import isCloudHosted from "~/utils/isCloudHosted"; import { changeLanguage, detectLanguage } from "~/utils/language"; +import ErrorUnknown from "../Errors/ErrorUnknown"; import Login from "../Login"; import Document from "./components/Document"; import Loading from "./components/Loading"; @@ -178,8 +183,10 @@ function SharedDocumentScene(props: Props) { } ); - } else { + } else if (error instanceof NotFoundError) { return ; + } else { + return ; } } diff --git a/app/scenes/Document/components/DataLoader.tsx b/app/scenes/Document/components/DataLoader.tsx index 9d8b0c777e..0c6072edee 100644 --- a/app/scenes/Document/components/DataLoader.tsx +++ b/app/scenes/Document/components/DataLoader.tsx @@ -10,6 +10,7 @@ import Error402 from "~/scenes/Errors/Error402"; import Error403 from "~/scenes/Errors/Error403"; import Error404 from "~/scenes/Errors/Error404"; import ErrorOffline from "~/scenes/Errors/ErrorOffline"; +import ErrorUnknown from "~/scenes/Errors/ErrorUnknown"; import { useDocumentContext } from "~/components/DocumentContext"; import useCurrentTeam from "~/hooks/useCurrentTeam"; import useCurrentUser from "~/hooks/useCurrentUser"; @@ -220,8 +221,10 @@ function DataLoader({ match, children }: Props) { ) : error instanceof AuthorizationError ? ( - ) : ( + ) : error instanceof NotFoundError ? ( + ) : ( + ); } diff --git a/app/scenes/Errors/ErrorUnknown.tsx b/app/scenes/Errors/ErrorUnknown.tsx new file mode 100644 index 0000000000..a27bac6fc2 --- /dev/null +++ b/app/scenes/Errors/ErrorUnknown.tsx @@ -0,0 +1,36 @@ +import { Trans, useTranslation } from "react-i18next"; +import Flex from "@shared/components/Flex"; +import Button from "~/components/Button"; +import CenteredContent from "~/components/CenteredContent"; +import Empty from "~/components/Empty"; +import Heading from "~/components/Heading"; +import PageTitle from "~/components/PageTitle"; +import { navigateToHome } from "~/actions/definitions/navigation"; +import useActionContext from "~/hooks/useActionContext"; + +const ErrorUnknown = () => { + const { t } = useTranslation(); + const context = useActionContext(); + + return ( + + + {t("Something went wrong")} + + + + Sorry, an unknown error occurred loading the page. Please try again + or contact support if the issue persists. + + + + + + + + ); +}; + +export default ErrorUnknown; diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 573e22f95e..4e10a19016 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -740,6 +740,8 @@ "Your account has been suspended": "Your account has been suspended", "Warning Sign": "Warning Sign", "A workspace admin ({{ suspendedContactEmail }}) has suspended your account. To re-activate your account, please reach out to them directly.": "A workspace admin ({{ suspendedContactEmail }}) has suspended your account. To re-activate your account, please reach out to them directly.", + "Something went wrong": "Something went wrong", + "Sorry, an unknown error occurred loading the page. Please try again or contact support if the issue persists.": "Sorry, an unknown error occurred loading the page. Please try again or contact support if the issue persists.", "Created by me": "Created by me", "Weird, this shouldn’t ever be empty": "Weird, this shouldn’t ever be empty", "You haven’t created any documents yet": "You haven’t created any documents yet", @@ -897,7 +899,6 @@ "Remove search": "Remove search", "Any author": "Any author", "Search titles only": "Search titles only", - "Something went wrong": "Something went wrong", "Please try again or contact support if the problem persists": "Please try again or contact support if the problem persists", "No documents found for your search filters.": "No documents found for your search filters.", "Create personal API keys to authenticate with the API and programatically control\n your workspace's data. For more details see the developer documentation.": "Create personal API keys to authenticate with the API and programatically control\n your workspace's data. For more details see the developer documentation.",