isUndeclaredResponseError
Narrow a TanStack Query error to a response whose status the route does not declare.
Narrows an error from a query or mutation to UndeclaredResponseError. See the TanStack Query guide.
Parameters
| Parameter | Type | Description |
|---|---|---|
error | unknown | The error from a query or mutation |
UndeclaredResponseError
| Property | Type | Description |
|---|---|---|
status | number | The status the server returned |
body | unknown | The parsed response body |
headers | Record<string, string> | The response headers |
It extends Error, so retry, throwOnError, and error boundaries treat it as one.
When it is thrown
A route's declared statuses are the keys of its responses, plus 400 when the route has a body or query schema. Those arrive as data. Every other status throws.
A 200 or 404 is data. A 500 throws.