Skip to content

Errors

Class@tryyoursize/node

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 Error
statusnumber | undefinedRequired
codestring | undefinedRequired
docUrlstring | undefinedRequired
requestIdstring | undefinedRequired
rawunknownRequired
headersHeaders | undefinedRequired
issuesGarmentIssue[] | undefinedRequired

Values to fix, for 422 answers of the garment endpoints (schema GarmentRejected).

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?