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

Improve API error handling #731

Merged
merged 1 commit into from Apr 3, 2020
Merged

Improve API error handling #731

merged 1 commit into from Apr 3, 2020

Conversation

huanggze
Copy link

@huanggze huanggze commented Apr 2, 2020

Signed-off-by: huanggze loganhuang@yunify.com

The current way we handle error drops some info from errorType and error for some scenarios.

Consider a real response example below, we expect the error object carry more info than inconsistent body for response code.

HTTP OK
---
{
    "status":"error",
    "errorType":"internal",
    "error":"multiple matches for labels: many-to-one matching must be explicit (group_left/group_right)"
}

@huanggze
Copy link
Author

huanggze commented Apr 2, 2020

@beorn7

@huanggze huanggze changed the title Improve error handling Improve API error handling Apr 2, 2020
Signed-off-by: huanggze <loganhuang@yunify.com>
@beorn7
Copy link
Member

beorn7 commented Apr 2, 2020

@bboreham @joe-elliott you might have most context here. Does this make sense?

@beorn7 beorn7 self-requested a review April 2, 2020 11:00
@joe-elliott
Copy link
Contributor

Without knowing the details of prometheus's API response code it's hard to say definitively, but I do prefer the changes @huanggze has made to the existing code.

With these changes the error is only hardcoded to "inconsistent body for response code" if the body says "success" but the http status is error. Otherwise you always get the error as returned from prometheus which I like.

Copy link
Member

@beorn7 beorn7 left a comment

Choose a reason for hiding this comment

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

Thanks, everyone. This makes sense to me, too, from my limited understanding. (o:

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.

None yet

3 participants