Skip to content

Commit

Permalink
fix(DiscordRESTError): flattten response errors properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah committed Sep 17, 2024
1 parent 6893598 commit 684ad62
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/rest/DiscordRESTError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ export class DiscordRESTError extends Error {
if (!(fieldName in errors) || fieldName === 'message' || fieldName === 'code') {
continue;
}
if (fieldName === '_errors') {
messages = messages.concat(
errors._errors.map((obj: any) => `${keyPrefix ? `${keyPrefix}: ` : ''}${obj.message}`)
);
continue;
}
if (errors[fieldName]._errors) {
messages = messages.concat(
errors[fieldName]._errors.map((obj: any) => `${keyPrefix + fieldName}: ${obj.message}`)
Expand Down

0 comments on commit 684ad62

Please sign in to comment.