Skip to content

Errors

Classtryyoursize

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)
statusintRequired

The HTTP status.

codeOptional[str]Required

The stable error code (API error codes).

doc_urlOptional[str]Required

Link to the code's explanation.

request_idOptional[str]Required

Quote it to support.

bodyDict[str, Any]Required

The parsed error body.

issueslistRequired

Garment issues of a 422; empty otherwise.

try:
tys.products.retrieve("NO-SUCH-SKU")
except tryyoursize.NotFoundError:
pass
except tryyoursize.APIError as err:
print(err.status, err.code, err.request_id)

Was this page helpful?