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

add StatusError to api package #11054

Merged
merged 2 commits into from
Sep 20, 2021
Merged

add StatusError to api package #11054

merged 2 commits into from
Sep 20, 2021

Conversation

acpana
Copy link
Contributor

@acpana acpana commented Sep 16, 2021

Overview

This PR adds a StatusError struct to the api package. Now devs can unwrap the errors returned thru query() or write() funcs and inspect the error code programatically.

Issue Related

#10865

Notes:

  • added a requireHttpCodes method to mark acceptable codes (200, 429, etc)
    • adoption of that func to all/ most doRequest() calls can be added in a subsequent PR
  • this PR mostly builds on feedback from [API] Handle plain text errors in client #8816

PR Checklist

[x] go fmt
[x] go mod
[x] n/a pr/changelog -- no "public" api changes

@hashicorp-cla
Copy link

hashicorp-cla commented Sep 16, 2021

CLA assistant check
All committers have signed the CLA.

@vercel vercel bot temporarily deployed to Preview – consul September 16, 2021 05:22 Inactive
@acpana acpana added the pr/no-changelog PR does not need a corresponding .changelog entry label Sep 16, 2021
@vercel vercel bot temporarily deployed to Preview – consul September 16, 2021 18:18 Inactive
@vercel vercel bot temporarily deployed to Preview – consul September 16, 2021 19:05 Inactive
Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

Thank you for working on this!

I haven't had a chance to look at the diff yet, but left a response to your question below.

api/operator_autopilot_test.go Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview – consul September 17, 2021 19:18 Inactive
@acpana acpana marked this pull request as ready for review September 17, 2021 19:40
@acpana
Copy link
Contributor Author

acpana commented Sep 17, 2021

@ShimmerGlass thanks for your work in #8816 ; i followed up on @dnephin's feedback w this PR.

Feel free to comment / add any input here but no pressure !

Copy link
Contributor

@kisunji kisunji left a comment

Choose a reason for hiding this comment

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

minor nit-picky comments but otherwise looks great!

api/api.go Outdated Show resolved Hide resolved
api/operator_autopilot.go Outdated Show resolved Hide resolved
api/api.go Outdated Show resolved Hide resolved
Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

Nice! LGTM

I left a couple comments about some possible stylistic changes, but nothing that should block a merge

api/api.go Show resolved Hide resolved
api/api.go Outdated Show resolved Hide resolved
Signed-off-by: FFMMM <FFMMM@users.noreply.github.com>
@vercel vercel bot temporarily deployed to Preview – consul September 20, 2021 20:26 Inactive
@acpana acpana merged commit 377c3a9 into hashicorp:main Sep 20, 2021
@hc-github-team-consul-core
Copy link
Collaborator

🍒 If backport labels were added before merging, cherry-picking will start automatically.

To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/450932.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/no-changelog PR does not need a corresponding .changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants