diff --git a/src/rest/DiscordAPIError.js b/src/rest/DiscordAPIError.js index 580723bf2..c90ee4f5a 100644 --- a/src/rest/DiscordAPIError.js +++ b/src/rest/DiscordAPIError.js @@ -3,12 +3,18 @@ * @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'; this.message = error.message && flattened ? `${error.message}\n${flattened}` : error.message || flattened; + /** + * The HTTP method used for the request + * @type {string} + */ + this.method = method; + /** * The path of the request relative to the HTTP endpoint * @type {string} diff --git a/src/rest/handlers/RequestHandler.js b/src/rest/handlers/RequestHandler.js index 9137d6a49..d5b67c91d 100644 --- a/src/rest/handlers/RequestHandler.js +++ b/src/rest/handlers/RequestHandler.js @@ -80,7 +80,8 @@ class RequestHandler { this.queue.unshift(item); finish(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); finish(); } } else {