Skip to content

Commit 7a38fee

Browse files
committed
Replace error boundary in root.tsx with RouteErrorBoundary
Since RouteErrorBoundary now also does Sentry logging, I saw no reason to keep another error boundary implementation around.
1 parent 874b480 commit 7a38fee

File tree

2 files changed

+2
-40
lines changed

2 files changed

+2
-40
lines changed

apps/cyberstorm-remix/app/root.tsx

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ import {
1010
ScrollRestoration,
1111
type ShouldRevalidateFunctionArgs,
1212
type UIMatch,
13-
isRouteErrorResponse,
1413
useLoaderData,
1514
useLocation,
1615
useMatches,
17-
useRouteError,
1816
} from "react-router";
1917
// import { LinksFunction } from "@remix-run/react/dist/routeModules";
2018
import { Provider as RadixTooltip } from "@radix-ui/react-tooltip";
@@ -30,7 +28,7 @@ import {
3028
import { DapperTs } from "@thunderstore/dapper-ts";
3129
import { type CurrentUser } from "@thunderstore/dapper/types";
3230

33-
import { captureRemixErrorBoundaryError, withSentry } from "@sentry/remix";
31+
import { withSentry } from "@sentry/remix";
3432
import { memo, type ReactNode, Suspense, useEffect, useRef } from "react";
3533
import { useHydrated } from "remix-utils/use-hydrated";
3634
import Toast from "@thunderstore/cyberstorm/src/newComponents/Toast";
@@ -600,42 +598,7 @@ function App() {
600598
}
601599

602600
export default withSentry(App);
603-
604-
// REMIX TODO: We don't have any data available in the root ErrorBoundary, so we might want to change the designs
605-
export function ErrorBoundary() {
606-
// REMIX TODO: We need to call the loader separately somehow to get the CurrentUser
607-
// const loaderOutput = useLoaderData<RootLoadersType>();
608-
// const parsedLoaderOutput: {
609-
// envStuff: { ENV: { PUBLIC_API_URL: string } };
610-
// sessionId: string | null;
611-
// currentUser: CurrentUser;
612-
// } = JSON.parse(JSON.stringify(loaderOutput));
613-
const error = useRouteError();
614-
if (import.meta.env.PROD) {
615-
captureRemixErrorBoundaryError(error);
616-
} else if (import.meta.env.DEV) {
617-
console.log(error);
618-
}
619-
const isResponseError = isRouteErrorResponse(error);
620-
return (
621-
<div className="error">
622-
<div
623-
className="error__glitch"
624-
data-text={isResponseError ? error.status : 500}
625-
>
626-
<span>{isResponseError ? error.status : 500}</span>
627-
</div>
628-
<div className="error__description">
629-
{isResponseError ? error.data : "Internal server error"}
630-
</div>
631-
{!isResponseError && (
632-
<div className="error__flavor">
633-
Beep boop. Server something error happens.
634-
</div>
635-
)}
636-
</div>
637-
);
638-
}
601+
export { RouteErrorBoundary as ErrorBoundary } from "app/commonComponents/ErrorBoundary";
639602

640603
// Temporary solution for implementing ads
641604
// REMIX TODO: Move to dynamic html

apps/cyberstorm-remix/docs/error-boundary.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export { RouteErrorBoundary as ErrorBoundary } from "app/commonComponents/ErrorB
1414

1515
### TODO
1616

17-
- Consider replacing the error boundary in `root.tsx` with this one
1817
- Use `RouteErrorBoundary` in route components
1918
- Add "retry buttons" (e.g. reloading the page on 500 series of errors)
2019
- As `RouteErrorBoundary` is all-or-nothing solution when it comes to rendering, consider if there's a need for more granular non-route component level error boundaries. We might not need or want to use them, as error boundaries are intended more for render time errors, and any errors caused by user interaction should be handled by the component logic itself

0 commit comments

Comments
 (0)