Skip to content

Commit

Permalink
Add delay to RateLimitedError
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanDMC committed Aug 18, 2024
1 parent 62c4d63 commit e8fbf1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rest/RequestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default class RequestHandler {
if (delay) {
if (delay > this.options.maxRatelimitRetryWindow) {
cb();
return reject(new RateLimitedError(`Ratelimit on "${options.method} ${route}" exceeds the maximum retry window (${delay} > ${this.options.maxRatelimitRetryWindow})`));
return reject(new RateLimitedError(`Ratelimit on "${options.method} ${route}" exceeds the maximum retry window (${delay} > ${this.options.maxRatelimitRetryWindow})`, delay));
}
setTimeout(() => {
cb();
Expand Down
4 changes: 3 additions & 1 deletion lib/util/Errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ export class GatewayError extends Error {
}

export class RateLimitedError extends Error {
delay: number;
override name = "RateLimitedError";
constructor(message: string) {
constructor(message: string, delay: number) {
super(message);
this.delay = delay;
}
}

0 comments on commit e8fbf1e

Please sign in to comment.