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

Slightly improve API error handling #4565

Closed
wants to merge 2 commits into from

Conversation

jamlo
Copy link
Contributor

@jamlo jamlo commented Sep 30, 2024

This commit tries to fix the "FromHttpResponse" function. Returning 2 errors from a function can be confusing and uncommon in Golang, especially if the function only returns these 2 errors.

The new code will return one error, which is always an APIError, and it also improves the error messaging wording, adding more details in the output.

Several more tweaks can be done to the current error message handling if needed.

Copy link
Member

@frrist frrist left a comment

Choose a reason for hiding this comment

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

Good stuff,

Few comments, address them if you'd like, but they are non-blocking.

pkg/publicapi/apimodels/error.go Show resolved Hide resolved
pkg/publicapi/apimodels/error.go Outdated Show resolved Hide resolved
pkg/publicapi/client/v2/client.go Outdated Show resolved Hide resolved
@wdbaruni wdbaruni requested a review from udsamani October 1, 2024 05:28
This commit tries to fix the "FromHttpResponse" function. Returning 2 errors from
a function can be confusing and uncommon in Golang, especially if the function
only returns these 2 errors.

The new code code will return one error, which is always an APIError, and
it also improves the error messaging wording, adding more details in the output.

Several more tweaks can be done to the current error message handling
if needed.
@wdbaruni
Copy link
Member

wdbaruni commented Oct 8, 2024

What is the status of this PR? @jamlo feel free to merge if all comments are addressed

@jamlo
Copy link
Contributor Author

jamlo commented Oct 8, 2024

@wdbaruni since this PR was created (through a fork) before I had access to the repo, I will close this one, and create another one from a branch to close the loop.

@jamlo jamlo mentioned this pull request Oct 8, 2024
@jamlo
Copy link
Contributor Author

jamlo commented Oct 8, 2024

Closing this PR in favor of #4607

@jamlo jamlo closed this Oct 8, 2024
jamlo added a commit that referenced this pull request Oct 8, 2024
This PR tries to fix the "FromHttpResponse" function. Returning 2 errors
from a function can be confusing and uncommon in Golang, especially if
the function only returns these 2 errors.

The new code will return one error, which is always an APIError, and it
also improves the error messaging wording, adding more details in the
output.

Several more tweaks can be done to the current error message handling if
needed.

Note: this is identical to [PR
4565](#4565), though
created from a branch, and not a fork.
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.

4 participants