Errors
Every exception is a TryYourSizeError. API answers raise an APIError subclass by status: InvalidRequestError (400, 422; issues for garments), AuthenticationError (401), PermissionDeniedError (403), NotFoundError (404), ConflictError (409), RateLimitError (429, retry_after), ServerError (5xx). APIConnectionError when no answer came; SignatureVerificationError for webhooks.
class APIError(TryYourSizeError)Attributes of APIError
Section titled “Attributes of APIError”statusintRequiredThe HTTP status.
codeOptional[str]RequiredThe stable error code (API error codes).
doc_urlOptional[str]RequiredLink to the code's explanation.
request_idOptional[str]RequiredQuote it to support.
bodyDict[str, Any]RequiredThe parsed error body.
issueslistRequiredGarment issues of a 422; empty otherwise.
Example
Section titled “Example”try: tys.products.retrieve("NO-SUCH-SKU")except tryyoursize.NotFoundError: passexcept tryyoursize.APIError as err: print(err.status, err.code, err.request_id)import { TryYourSizeError, RateLimitError } from "@tryyoursize/node";
try { await tys.products.retrieve("NO-SUCH-SKU");} catch (err) { if (err instanceof RateLimitError) await sleep((err.retryAfter ?? 1) * 1000); else if (err instanceof TryYourSizeError) console.error(err.status, err.code, err.requestId);}Was this page helpful?
Thank you. We read every answer.