diff --git a/src/client/rest/DiscordAPIError.js b/src/client/rest/DiscordAPIError.js index 1b9c194d9..f5f833641 100644 --- a/src/client/rest/DiscordAPIError.js +++ b/src/client/rest/DiscordAPIError.js @@ -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; } /** diff --git a/src/client/rest/RequestHandlers/Burst.js b/src/client/rest/RequestHandlers/Burst.js index 1f941af31..0bbae51c2 100644 --- a/src/client/rest/RequestHandlers/Burst.js +++ b/src/client/rest/RequestHandlers/Burst.js @@ -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 { diff --git a/src/client/rest/RequestHandlers/Sequential.js b/src/client/rest/RequestHandlers/Sequential.js index 257facbbd..94ecd1dcb 100644 --- a/src/client/rest/RequestHandlers/Sequential.js +++ b/src/client/rest/RequestHandlers/Sequential.js @@ -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 {