feat/fix: add DiscordAPIError#path and fixed Burst request handler handling api errors (#1867)

This commit is contained in:
SpaceEEC
2017-09-01 16:05:22 +02:00
committed by Crawl
parent 425efe1fe4
commit 95e22c2f12
3 changed files with 9 additions and 3 deletions

View File

@@ -3,12 +3,18 @@
* @extends Error
*/
class DiscordAPIError extends Error {
constructor(error) {
constructor(path, error) {
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 path of the request relative to the HTTP endpoint
* @type {string}
*/
this.path = path;
/**
* HTTP error code returned by Discord
* @type {number}