Skip to content

Errors

TikTokShopError, its code and httpStatus, and how each kind of failure is reported in the TypeScript SDK.

Every failed call throws TikTokShopError, with code, message, requestId, httpStatus and the original error as cause. The same rules apply in all eight SDKs; see errors.

What happenedcodehttpStatus
TikTok’s reply has a non-zero code, even on HTTP 200TikTok’s codethe status
A non-2xx replyTikTok’s non-zero code if the body has one, else the HTTP statusthe status
A 2xx reply that can’t be read: not a JSON object, a code that isn’t an integer, a body that doesn’t fit its model, or a token reply without data-1the status
No HTTP response at all: connection refused, DNS, TLS, or a timeout-1unset

The generated models copy scalar fields as sent, without checking their type. A field that should hold a model but isn’t a JSON object, or should hold a list of models but isn’t a list, is the -1 error, at any depth.

  • Look up TikTok’s code. Each operation’s error codes are listed in the API reference (x-tts-error-codes in the spec).
  • Keep the requestId. TikTok’s support asks for it.
  • Redirects are errors. With the default fetch, a 3xx reply is an error whose code and httpStatus are the status, and the client does not follow it.
  • Secrets stay out of errors. Token calls never put the app secret, the authorization code or the refresh token in the error message.