Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Util): throw token invalid for fetching rec. shard amount #4779

Merged
merged 2 commits into from Sep 4, 2020

Conversation

almostSouji
Copy link
Member

@almostSouji almostSouji commented Sep 2, 2020

Please describe the changes this PR makes and why it should be merged:

As #4778 has brough to light we currently throw the response if an invalid token is provided when fetching the recommended amount of shards from the API.

While changing the kind of error to throw here could be framed as major i am so bold to say that this can not be deliberate design (as it results in the rather unhelpful #<Response> being thrown) and thus will tag it as patch and consider it a fix rather than a feature.

discord.js/src/util/Util.js

Lines 246 to 247 in b0ab37d

if (res.ok) return res.json();
throw res;

Seeing that providing an invalid token will result in a 401 response adding a line to throw TOKEN_INVALID instead if that's the case provides more context to the user but still enables other faults to be propagated.

Status

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

Semantic versioning classification:

  • This PR changes the library's interface (methods or parameters added)
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

src/util/Util.js Outdated Show resolved Hide resolved
@iCrawl iCrawl merged commit 77b6a7d into discordjs:master Sep 4, 2020
@almostSouji almostSouji deleted the fix-token-invalid branch September 27, 2020 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants