feat: add root and route-level error boundaries

This commit is contained in:
lila 2026-04-26 08:45:18 +02:00
parent e3d28e4127
commit 0da8397940
4 changed files with 109 additions and 0 deletions

View file

@ -2,6 +2,7 @@ import { createRootRoute, Outlet } from "@tanstack/react-router";
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
import Navbar from "../components/navbar/NavBar";
import NotFound from "../components/NotFound";
import RootError from "../components/RootError";
const RootLayout = () => {
return (
@ -18,4 +19,5 @@ const RootLayout = () => {
export const Route = createRootRoute({
component: RootLayout,
notFoundComponent: NotFound,
errorComponent: RootError,
});

View file

@ -4,6 +4,7 @@ import type { GameSession, GameRequest, AnswerResult } from "@lila/shared";
import { QuestionCard } from "../components/game/QuestionCard";
import { ScoreScreen } from "../components/game/ScoreScreen";
import { GameSetup } from "../components/game/GameSetup";
import RouteError from "../components/RouteError";
import { authClient } from "../lib/auth-client";
type GameStartResponse = { success: true; data: GameSession };
@ -127,6 +128,7 @@ function Play() {
export const Route = createFileRoute("/play")({
component: Play,
errorComponent: RouteError,
beforeLoad: async () => {
const { data: session } = await authClient.getSession();
if (!session) {