Error handling
Any non-2xx response rejects with an ApiError. Uploads that exceed their size
limit reject before the request is made, with a plain Error.
ApiError
| Property | Type | Description |
|---|---|---|
message | string | Server-supplied message, or "An error occurred". |
code | string | Server-supplied error code, or "UNKNOWN". "TIMEOUT" when the request was aborted. |
statusCode | number | HTTP status code. 408 for timeouts. |
import { ApiError } from "@thenoughtyfox/noughty-tours-web-sdk";
try {
await NTController.tours.get(tourId);
} catch (error) {
if (error instanceof ApiError && error.statusCode === 404) {
// Tour does not exist, or this token cannot see it.
}
throw error;
}
Timeouts
Requests abort after 15 seconds and reject with an ApiError whose code is
TIMEOUT and statusCode is 408.
What a 401 usually means
Almost every authentication failure is one of a short list — check these before digging further:
- Your issuer is not registered yet.
- The
audclaim is not the API origin the SDK calls. - Your JWKS is unreachable from the public internet, or the
kidin the token header is not in it. - The token has expired, because
getBearerToken()returned a cached one past its TTL.
Upload size errors
uploadThumbnail and uploadPlan check the file locally and reject with a plain
Error — not an ApiError — when it is too large, so no request is sent.
| Upload | Limit | Content type |
|---|---|---|
| Scan thumbnail | 500 KB | image |
| Floor plan | 1 MB | application/json |