404 fallback vs. +error.ts
Use a rest route for "not found" pages. Use +error.ts
to handle errors thrown
by matched routes. Only the nearest +error.ts
runs; error handlers don't compose.
404 fallback ≠ error handler. The fallback only runs when nothing else matched.
+error.ts
runs when a matched route (or guard/layout) throws.// routes/[[...path]].ts
import route from "primate/route";
route.get(() => new Response("Not found", { status: 404 }));
// routes/+error.ts
import route from "primate/route";
import redirect from "primate/response/redirect";
route.get(() => redirect("/")); // or return a rendered error view