Skip to content

fix: improve error message when CF API responds with an error #1122

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

Merged
merged 3 commits into from
May 27, 2022

Conversation

petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented May 26, 2022

I find the current message confusing. The response is not bad it is a valid response saying that the request failed.

@changeset-bot
Copy link

changeset-bot bot commented May 26, 2022

🦋 Changeset detected

Latest commit: 5b67d2d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented May 26, 2022

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2392812815/npm-package-wrangler-1122

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/1122/npm-package-wrangler-1122

Or you can use npx with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/2392812815/npm-package-wrangler-1122 dev path/to/script.js

For example if you have an invalid CF_API_TOKEN and try running `wrangler whoami`
you now get the additional `6111` error information:

```
✘ [ERROR] A request to the Cloudflare API (/user) failed.

  Invalid request headers [code: 6003]
  - Invalid format for Authorization header [code: 6111]
```
Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need more information for sleuthing these routes issues.

@@ -2754,7 +2754,7 @@ export async function main(argv: string[]): Promise<void> {
e.notes.push({
text: "\nIf you think this is a bug, please open an issue at: https://github.com/cloudflare/wrangler2/issues/new",
});
logger.error(formatMessage(e));
logger.log(formatMessage(e));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using .log() here because the message already has an ERROR prefix, so we don't want .error() to add it again.

@petebacondarwin petebacondarwin merged commit c2d2f44 into cloudflare:main May 27, 2022
@github-actions github-actions bot mentioned this pull request May 27, 2022
@petebacondarwin petebacondarwin deleted the not-a-bad-response branch May 27, 2022 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants