mirror of
https://github.com/danbulant/discord.js
synced 2026-05-27 22:11:53 +00:00
feat(DiscordAPIError): backport method property (#2536)
This commit is contained in:
parent
a89de09855
commit
8700e965c5
3 changed files with 11 additions and 3 deletions
|
|
@ -3,7 +3,7 @@
|
|||
* @extends Error
|
||||
*/
|
||||
class DiscordAPIError extends Error {
|
||||
constructor(path, error) {
|
||||
constructor(path, error, method) {
|
||||
super();
|
||||
const flattened = this.constructor.flattenErrors(error.errors || error).join('\n');
|
||||
this.name = 'DiscordAPIError';
|
||||
|
|
@ -20,6 +20,12 @@ class DiscordAPIError extends Error {
|
|||
* @type {number}
|
||||
*/
|
||||
this.code = error.code;
|
||||
|
||||
/**
|
||||
* The HTTP method used for the request
|
||||
* @type {string}
|
||||
*/
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ class BurstRequestHandler extends RequestHandler {
|
|||
this.resetTimeout = null;
|
||||
}, 1e3 + this.client.options.restTimeOffset);
|
||||
} else {
|
||||
item.reject(err.status >= 400 && err.status < 500 ? new DiscordAPIError(res.request.path, res.body) : err);
|
||||
item.reject(err.status >= 400 && err.status < 500 ?
|
||||
new DiscordAPIError(res.request.path, res.body, res.request.method) : err);
|
||||
this.handle();
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ class SequentialRequestHandler extends RequestHandler {
|
|||
this.queue.unshift(item);
|
||||
this.restManager.client.setTimeout(resolve, 1e3 + this.restManager.client.options.restTimeOffset);
|
||||
} else {
|
||||
item.reject(err.status >= 400 && err.status < 500 ? new DiscordAPIError(res.request.path, res.body) : err);
|
||||
item.reject(err.status >= 400 && err.status < 500 ?
|
||||
new DiscordAPIError(res.request.path, res.body, res.request.method) : err);
|
||||
resolve(err);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue