Skip to content

Commit

Permalink
refactor: remove duplicate functionality (#314)
Browse files Browse the repository at this point in the history
The `isConflict()` method duplicates the functionality of the
`IsError()` method.
  • Loading branch information
apricote authored Sep 5, 2023
1 parent b77d9e0 commit 8043160
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions hcloud/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (c *Client) Do(r *http.Request, v interface{}) (*Response, error) {
err = errorFromResponse(resp, body)
if err == nil {
err = fmt.Errorf("hcloud: server responded with status code %d", resp.StatusCode)
} else if isConflict(err) {
} else if IsError(err, ErrorCodeConflict) {
c.backoff(retries)
retries++
continue
Expand All @@ -309,14 +309,6 @@ func (c *Client) Do(r *http.Request, v interface{}) (*Response, error) {
}
}

func isConflict(error error) bool {
err, ok := error.(Error)
if !ok {
return false
}
return err.Code == ErrorCodeConflict
}

func (c *Client) backoff(retries int) {
time.Sleep(c.backoffFunc(retries))
}
Expand Down

0 comments on commit 8043160

Please sign in to comment.