feat(DiscordAPIError): add method property (#2530)

This commit is contained in:
Kyra
2018-05-03 08:01:27 +02:00
committed by SpaceEEC
parent 17d2c2efb8
commit 62605c4470
2 changed files with 9 additions and 2 deletions

View File

@@ -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}