Skip to content

Commit

Permalink
feat: add error screen for network issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jog1t committed Jan 17, 2025
1 parent 07e50ec commit 626d711
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
18 changes: 14 additions & 4 deletions frontend/apps/hub/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import { PageLayout } from "@rivet-gg/components/layout";
import * as Sentry from "@sentry/react";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { PersistQueryClientProvider } from "@tanstack/react-query-persist-client";
import { RouterProvider, createRouter } from "@tanstack/react-router";
import {
CatchBoundary,
RouterProvider,
createRouter,
} from "@tanstack/react-router";
import { Suspense } from "react";
import { LayoutedErrorComponent } from "./components/error-component";
import { ThirdPartyProviders } from "./components/third-party-providers";
import { AuthProvider, useAuth } from "./domains/auth/contexts/auth";
import { routeMasks } from "./lib/route-masks";
Expand Down Expand Up @@ -63,9 +68,14 @@ export function App({ cacheKey }: { cacheKey?: string }) {
<ThirdPartyProviders>
<Suspense fallback={<FullscreenLoading />}>
<TooltipProvider>
<AuthProvider>
<InnerApp />
</AuthProvider>
<CatchBoundary
getResetKey={() => ""}
errorComponent={LayoutedErrorComponent}
>
<AuthProvider>
<InnerApp />
</AuthProvider>
</CatchBoundary>
</TooltipProvider>
</Suspense>

Expand Down
12 changes: 12 additions & 0 deletions frontend/apps/hub/src/components/error-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Code,
Text,
} from "@rivet-gg/components";
import { PageLayout } from "@rivet-gg/components/layout";
import { Icon, faBomb, faLock } from "@rivet-gg/icons";
import * as Sentry from "@sentry/react";
import {
Expand All @@ -18,6 +19,7 @@ import {
} from "@tanstack/react-query";
import { type ErrorComponentProps, useRouter } from "@tanstack/react-router";
import { useEffect } from "react";
import { NetworkIssueError } from "./network-issue-error";
import { NotFoundComponent } from "./not-found-component";

export const ErrorComponent = ({
Expand Down Expand Up @@ -72,6 +74,8 @@ export const ErrorComponent = ({
}
} else if (!error) {
return <NotFoundComponent />;
} else if ("statusCode" in error && "body" in error) {
return <NetworkIssueError />;
}

return (
Expand Down Expand Up @@ -106,3 +110,11 @@ export const ErrorComponent = ({
</Card>
);
};

export function LayoutedErrorComponent(props: ErrorComponentProps) {
return (
<PageLayout.Root>
<ErrorComponent {...props} />
</PageLayout.Root>
);
}

0 comments on commit 626d711

Please sign in to comment.