UNPKG

lago-javascript-client

Version:
20 lines (19 loc) 724 B
/** * Error class for rate limit (HTTP 429) responses */ export class LagoRateLimitError extends Error { limit; remaining; reset; // seconds until window resets retryAfter; // milliseconds to wait before retrying constructor(limit, remaining, reset) { super(`Rate limit exceeded. Limit: ${limit}, Remaining: ${remaining}, Reset in: ${reset}s`); this.name = "LagoRateLimitError"; this.limit = limit; this.remaining = remaining; this.reset = reset; this.retryAfter = reset * 1000; // Convert seconds to milliseconds // Maintain proper prototype chain for instanceof checks Object.setPrototypeOf(this, LagoRateLimitError.prototype); } }