diff --git a/apps/cyberstorm-remix/app/root.tsx b/apps/cyberstorm-remix/app/root.tsx index 89897a7f1..34af8c075 100644 --- a/apps/cyberstorm-remix/app/root.tsx +++ b/apps/cyberstorm-remix/app/root.tsx @@ -1,5 +1,7 @@ -// The styles need to be imported at the beginning, so that the layers are correctly set up -// eslint-disable-next-line prettier/prettier +// sort-imports-ignore +import "./styles"; +// NOTE: The sort-imports-ignore is needed here to prevent css layers from not being loaded in the correct order, feel free to remove the ignore momentarily to sort imports + // import { LinksFunction } from "@remix-run/react/dist/routeModules"; import { Provider as RadixTooltip } from "@radix-ui/react-tooltip"; import { captureRemixErrorBoundaryError, withSentry } from "@sentry/remix"; @@ -8,6 +10,11 @@ import { type publicEnvVariablesType, } from "cyberstorm/security/publicEnvVariables"; import { LinkLibrary } from "cyberstorm/utils/LinkLibrary"; +import { NimbusAwaitErrorElement } from "cyberstorm/utils/errors/NimbusErrorBoundary"; +import { + type UserFacingErrorPayload, + parseUserFacingErrorPayload, +} from "cyberstorm/utils/errors/userFacingErrorResponse"; import { type ReactNode, Suspense, memo, useEffect, useRef } from "react"; import { Await, @@ -35,8 +42,6 @@ import { isRecord, } from "@thunderstore/cyberstorm"; import { Toast } from "@thunderstore/cyberstorm"; -import "@thunderstore/cyberstorm-theme/css"; -import "@thunderstore/cyberstorm/css"; import { type CurrentUser } from "@thunderstore/dapper"; import { DapperTs } from "@thunderstore/dapper-ts"; import { type RequestConfig } from "@thunderstore/thunderstore-api"; @@ -50,10 +55,7 @@ import { import type { Route } from "./+types/root"; import { Footer } from "./commonComponents/Footer/Footer"; -// Annoying prettier issue, where it wants to insert styles import here -// eslint-disable-next-line prettier/prettier import { NavigationWrapper } from "./commonComponents/Navigation/NavigationWrapper"; -import "./styles/index.css"; // REMIX TODO: https://remix.run/docs/en/main/route/links // export const links: LinksFunction = () => [{ rel: "stylesheet", href: styles }]; @@ -621,18 +623,36 @@ export function ErrorBoundary() { console.log(error); } const isResponseError = isRouteErrorResponse(error); + let payload: UserFacingErrorPayload | null = null; + + if (isResponseError) { + payload = parseUserFacingErrorPayload(error.data); + } + + const statusCode = payload?.status ?? (isResponseError ? error.status : 500); + const headline = + payload?.headline ?? + (isResponseError + ? error.statusText || `Error ${error.status}` + : "Internal server error"); + + const fallbackDescription = + isResponseError && typeof error.data === "string" + ? dedupeDescription(headline, error.data) + : undefined; + + const description = payload?.description ?? fallbackDescription; + const showDefaultFlavor = !payload && !isResponseError; return (