Skip to main content

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

PropertyTypeDescription
messagestringServer-supplied message, or "An error occurred".
codestringServer-supplied error code, or "UNKNOWN". "TIMEOUT" when the request was aborted.
statusCodenumberHTTP 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 aud claim is not the API origin the SDK calls.
  • Your JWKS is unreachable from the public internet, or the kid in 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.

UploadLimitContent type
Scan thumbnail500 KBimage
Floor plan1 MBapplication/json