refactor: clean up rate limit handling (#2694)

* refactor: clean up rate limit handling

* requested changes

* remove request mode option

* fix dupe requests

* hardcode reaction ratelimits

* suggested changes

* fix small thing

* re-add restTimeOffset

* move restTimeOffset a bit

* i swear i know english its my native language ok

* requested changes

* fix: a bit *too* pre-emptive with ratelimits, now less so

* fix: dapi error shoudl reject with path

* fix: make errors in execute catchable

* fix promise return

* rebase is hard
This commit is contained in:
Isabella
2018-08-23 23:29:44 -05:00
committed by Crawl
parent 82993fbe51
commit 13f46b924b
8 changed files with 215 additions and 175 deletions

31
src/rest/HTTPError.js Normal file
View File

@@ -0,0 +1,31 @@
class HTTPError extends Error {
constructor(message, name, code, method, path) {
super(message);
/**
* The name of the error
* @type {string}
*/
this.name = name;
/**
* HTTP error code returned from the request
* @type {number}
*/
this.code = code || 500;
/**
* 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;
}
}
module.exports = HTTPError;