/
RateLimitError.js
55 lines (46 loc) · 1.09 KB
/
RateLimitError.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
/**
* Represents a RateLimit error from a request.
* @extends Error
*/
class RateLimitError extends Error {
constructor({ timeout, limit, method, path, route, global }) {
super(`A ${global ? 'global ' : ''}rate limit was hit on route ${route}`);
/**
* The name of the error
* @type {string}
*/
this.name = 'RateLimitError';
/**
* Time until this rate limit ends, in milliseconds
* @type {number}
*/
this.timeout = timeout;
/**
* The HTTP method used for the request
* @type {string}
*/
this.method = method;
/**
* The path of the request relative to the HTTP endpoint
* @type {string}
*/
this.path = path;
/**
* The route of the request relative to the HTTP endpoint
* @type {string}
*/
this.route = route;
/**
* Whether this rate limit is global
* @type {boolean}
*/
this.global = global;
/**
* The maximum amount of requests of this endpoint
* @type {number}
*/
this.limit = limit;
}
}
module.exports = RateLimitError;