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

Provide a custom retryablehttp.ErrorHandler for more consistent returns using retries. #629

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

andrewsomething
Copy link
Member

This aims to solve a number of inconsistencies/issues when using WithRetryAndBackoffs. Currentlywhen a retry happens:

  • The final error response from the API is overwritten with the "giving up after x attempt(s)" error message. It does not include the final status code.
  • The error gets double nested. So calling err.Error() returns the messy looking Get "http://127.0.0.1:45035/foo": GET http://127.0.0.1:45035/foo giving up after 4 attempt(s)
  • The *godo.Response returned by the resource methods is nil if there is an error. That is not consistent with existing godo or net/http. If there is an HTTP response, even an errpr, it should be returned.

This uses a custom ErrorHandler in order to provide errors that are consistent with a *godo.ErrorResponse and a non-nil *godo.Response while still providing insight.

Copy link
Member

@danaelhe danaelhe left a comment

Choose a reason for hiding this comment

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

Just tried it in terraform and works well 👍 thanks!

@andrewsomething andrewsomething merged commit 21863bf into main Aug 17, 2023
7 checks passed
@andrewsomething andrewsomething deleted the asb/retry-error-handling branch August 17, 2023 21:25
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

2 participants