Please describe the problem you are having in as much detail as possible:
Stack trace: https://pastebin.com/raw/m7umq6q1
This messes up any error handlers that check if the error object is an instance of the DiscordAPIError class.
Include a reproducible code sample here, if possible:
Wait for a discord outage lol
Further details:
Priority this issue should have: low
[ ] I found this issue while running code on a __user account__
this is purposeful. Discord creates a specific body in 4xx errors which the APIError is designed to handle which isn't guaranteed or even likely to be there on a 5xx
The only additional property on the DiscordAPIError class is the code, which as far as I know, all internal server errors have. I do not understand why a new instance of this error class couldn't be thrown using the same error code and message of the original internal server error.
The bottom line remains. DiscordAPIError is intended to be used exclusively for regular API errors that are the result of a client-side issue. Any non 4xx error codes should be handled properly on your end. It is possible that we could make a more inclusive error that spans all Discord errors, which DiscordAPIError would then extend.
a 5xx error can come from any source in discord's backend chain going from cassandra to loqui to flask to google to cloudflare to you. These errors may not have a JSON body or may have no body at all. As of v11.2 we will automatically retry on a 5xx error anyway, so you do not need to worry about it.
DiscordAPIError as a name doesn't (at least imo) make it very clear that it's only for client-side issues, nor does that look obviously documented on the DiscordAPIError page of the documentation. It seems reasonable to group client-side issues together, but perhaps the error should be given a clearer name in some breaking update, or at least have this more clearly noted in the documentation?
I would be in favor of a more inclusive error to span all Discord errors, to help clients distinguish between that and e.g. a websocket error? (But this is an opinion as a newbie user of the library, so take it with a grain of salt.)
Maybe possibly add a ServerError instance for such events?
It's Hacktoberfest after all :^)
We have HTTPError in discord.js 12-dev.