mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
feat(Rest): show the data that is sent to Discord when an errors occurs (#5701)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* @extends Error
|
||||
*/
|
||||
class DiscordAPIError extends Error {
|
||||
constructor(path, error, method, status) {
|
||||
constructor(error, status, request) {
|
||||
super();
|
||||
const flattened = this.constructor.flattenErrors(error.errors || error).join('\n');
|
||||
this.name = 'DiscordAPIError';
|
||||
@@ -15,13 +15,13 @@ class DiscordAPIError extends Error {
|
||||
* The HTTP method used for the request
|
||||
* @type {string}
|
||||
*/
|
||||
this.method = method;
|
||||
this.method = request.method;
|
||||
|
||||
/**
|
||||
* The path of the request relative to the HTTP endpoint
|
||||
* @type {string}
|
||||
*/
|
||||
this.path = path;
|
||||
this.path = request.path;
|
||||
|
||||
/**
|
||||
* HTTP error code returned by Discord
|
||||
@@ -34,6 +34,15 @@ class DiscordAPIError extends Error {
|
||||
* @type {number}
|
||||
*/
|
||||
this.httpStatus = status;
|
||||
|
||||
/**
|
||||
* The data associated with the request that caused this error
|
||||
* @type {HTTPErrorData}
|
||||
*/
|
||||
this.requestData = {
|
||||
json: request.options.data,
|
||||
files: request.options.files ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user