mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
refactor: new node features (#5132)
Co-authored-by: Antonio Román <kyradiscord@gmail.com>
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
class DiscordAPIError extends Error {
|
||||
constructor(error, status, request) {
|
||||
super();
|
||||
const flattened = this.constructor.flattenErrors(error.errors || error).join('\n');
|
||||
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;
|
||||
this.message = error.message && flattened ? `${error.message}\n${flattened}` : error.message ?? flattened;
|
||||
|
||||
/**
|
||||
* The HTTP method used for the request
|
||||
@@ -61,7 +61,7 @@ class DiscordAPIError extends Error {
|
||||
|
||||
if (v._errors) {
|
||||
messages.push(`${newKey}: ${v._errors.map(e => e.message).join(' ')}`);
|
||||
} else if (v.code || v.message) {
|
||||
} else if (v.code ?? v.message) {
|
||||
messages.push(`${v.code ? `${v.code}: ` : ''}${v.message}`.trim());
|
||||
} else if (typeof v === 'string') {
|
||||
messages.push(v);
|
||||
|
||||
Reference in New Issue
Block a user