Skip to content

Commit

Permalink
Add timeout error retry handling
Browse files Browse the repository at this point in the history
  • Loading branch information
nmanoogian committed Oct 31, 2022
1 parent 995ba75 commit ec4ca5e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion doppler/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -129,7 +130,12 @@ func (client APIClient) PerformRequest(req *http.Request, params []QueryParam) (

r, err := httpClient.Do(req)
if err != nil {
return nil, &APIError{Err: err, Message: "Unable to load response"}
var retryAfter *time.Duration
if e, ok := err.(net.Error); ok && e.Timeout() {
retryAfter = getSecondsDuration(1)
}

return nil, &APIError{Err: err, Message: "Unable to load response", RetryAfter: retryAfter}
}
defer r.Body.Close()

Expand Down

0 comments on commit ec4ca5e

Please sign in to comment.