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 HTTPError extends Error {
|
||||
constructor(message, name, code, method, path) {
|
||||
constructor(message, name, code, request) {
|
||||
super(message);
|
||||
|
||||
/**
|
||||
@@ -24,13 +24,36 @@ class HTTPError 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;
|
||||
|
||||
/**
|
||||
* The HTTP data that was sent to Discord
|
||||
* @typedef {Object} HTTPErrorData
|
||||
* @property {*} json The JSON data that was sent
|
||||
* @property {HTTPAttachmentData[]} files The files that were sent with this request, if any
|
||||
*/
|
||||
|
||||
/**
|
||||
* The attachment data that is sent to Discord
|
||||
* @typedef {Object} HTTPAttachmentData
|
||||
* @property {string} name The file name
|
||||
* @property {Buffer} file The file buffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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