Errors
Every error of an API call is a TryYourSizeError subclass, by HTTP status: InvalidRequestError (400, 422), AuthenticationError (401), PermissionError (403), NotFoundError (404), ConflictError (409), RateLimitError (429, with retryAfter), APIError (5xx) and ConnectionError (no answer). Webhook checks throw SignatureVerificationError.
class TryYourSizeError extends ErrorProperties
Section titled “Properties”statusnumber | undefinedRequiredcodestring | undefinedRequireddocUrlstring | undefinedRequiredrequestIdstring | undefinedRequiredrawunknownRequiredheadersHeaders | undefinedRequiredissuesGarmentIssue[] | undefinedRequiredValues to fix, for 422 answers of the garment endpoints (schema GarmentRejected).
Example
Section titled “Example”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);}try: tys.products.retrieve("NO-SUCH-SKU")except tryyoursize.NotFoundError: passexcept tryyoursize.APIError as err: print(err.status, err.code, err.request_id)See also
Section titled “See also”Was this page helpful?
Thank you. We read every answer.