404
src/routes/_404.tsx
_not-found.tsx is an alias for the same slot. This page does not wrap in _layout.tsx, but it still uses src/routes/_document.tsx. Include whatever chrome you need here.
Without this file, unmatched routes return plain text Not Found.
Uncaught errors
src/routes/_error.tsx
_layout.tsx. It still renders inside _document.tsx. SPA navigations that fail receive JSON { error } instead of this page.
Throwing vs redirecting
HTTPException(401) is correct for /api/*. On a document request it renders _error.tsx with { status: 401 } — not a login redirect.
Default output
If you skip_error.tsx, document requests get <pre>message</pre> and JSON requests get { "error": "message" } with the exception status.