ChemPal Documentation - v1.17.0
    Preparing search index...

    Function isRateLimited

    • True when a supplier answered 429 Too Many Requests. That is the supplier throttling us, not a bug here, so callers log it at warn instead of error.

      Parameters

      • error: unknown

        Whatever was thrown or rejected with

      Returns boolean

      true for an HttpError with status 429

      isRateLimited(new HttpError(429, 'Too Many Requests')); // true
      isRateLimited(new HttpError(403, 'Forbidden')); // false
      isRateLimited(new Error('HTTP Error: 429')); // false (not an HttpError)
      export function isRateLimited(error: unknown): boolean {
      return error instanceof HttpError && error.status === HttpStatus.TOO_MANY_REQUESTS;
      }