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 #4607

Merged
merged 1 commit into from
Oct 8, 2024
Merged

Improve API error handling #4607

merged 1 commit into from
Oct 8, 2024

Conversation

jamlo
Copy link
Contributor

@jamlo jamlo commented 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, though created from a branch, and not a fork.

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.
@jamlo jamlo merged commit 764831d into main Oct 8, 2024
3 of 4 checks passed
@jamlo jamlo deleted the jamlo/improve-api-error-handling branch October 8, 2024 14:51
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