Skip to content

Commit

Permalink
fix(DiscordRESTError): properly parse request errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah authored and TTtie committed Sep 19, 2024
1 parent e520e60 commit fa92a2e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/errors/DiscordRESTError.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ class DiscordRESTError extends Error {
if(!Object.hasOwn(errors, fieldName) || fieldName === "message" || fieldName === "code") {
continue;
}
if(fieldName === "_errors") {
messages = messages.concat(
errors._errors.map((obj) => `${keyPrefix ? `${keyPrefix}: ` : ""}${obj.message}`)
);
continue;
}
if(errors[fieldName]._errors) {
messages = messages.concat(errors[fieldName]._errors.map((obj) => `${keyPrefix + fieldName}: ${obj.message}`));
} else if(Array.isArray(errors[fieldName])) {
Expand Down

0 comments on commit fa92a2e

Please sign in to comment.