@@ -547,7 +547,7 @@ implementations.forEach((implementation) => {
547547 },
548548 {
549549 id: "render-route-error-response",
550- path: "render-route-error-response",
550+ path: "render-route-error-response/:id? ",
551551 lazy: () => import("./routes/render-route-error-response/home"),
552552 }
553553 ],
@@ -1535,17 +1535,22 @@ implementations.forEach((implementation) => {
15351535
15361536 export { ErrorBoundary } from "./home.client";
15371537
1538- export default function RenderRouteErrorResponse() {
1539- throw data({ message: "Test" }, { status: 400, statusText: "Oh no!" });
1538+ export default function RenderRouteErrorResponse({ params: { id } }) {
1539+ if (!id) throw new Response(null, { status: 400, statusText: "Oh no!" });
1540+
1541+ throw data({ message: id }, { status: 400, statusText: "Oh no!" });
15401542 }
15411543 ` ,
15421544 "src/routes/render-route-error-response/home.client.tsx" : js `
15431545 "use client";
1544- import { useRouteError } from "react-router";
1546+ import { useRouteError, isRouteErrorResponse } from "react-router";
15451547
15461548 export function ErrorBoundary() {
15471549 const error = useRouteError();
1548- return <p>{error.status} {error.statusText} {error.data.message}</p>
1550+ if (isRouteErrorResponse(error)) {
1551+ return <p>{error.status} {error.statusText} {error.data?.message || "no"}</p>;
1552+ }
1553+ return <p>Oh no D:</p>;
15491554 }
15501555 ` ,
15511556 } ,
@@ -1871,10 +1876,19 @@ implementations.forEach((implementation) => {
18711876 await expect ( page . getByText ( "Example Domain" ) ) . toBeAttached ( ) ;
18721877 } ) ;
18731878
1874- test ( "Support throwing data() responses " , async ( { page } ) => {
1879+ test . only ( "Support throwing Responses " , async ( { page } ) => {
18751880 await page . goto (
18761881 `http://localhost:${ port } /render-route-error-response` ,
18771882 ) ;
1883+ await expect ( page . getByText ( "400 Oh no! no" ) ) . toBeAttached ( ) ;
1884+ } ) ;
1885+
1886+ test . only ( "Support throwing data() responses with data" , async ( {
1887+ page,
1888+ } ) => {
1889+ await page . goto (
1890+ `http://localhost:${ port } /render-route-error-response/Test` ,
1891+ ) ;
18781892 await expect ( page . getByText ( "400 Oh no! Test" ) ) . toBeAttached ( ) ;
18791893 } ) ;
18801894 } ) ;
0 commit comments