From b599e244e84b835355a4732815efb691a32fa58b Mon Sep 17 00:00:00 2001 From: Pyotr Krutov Date: Mon, 27 Jun 2022 10:23:01 +0300 Subject: [PATCH] made error message after HTTP 500 retry more informative --- decort/controller.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/decort/controller.go b/decort/controller.go index 25e27ea..27bd20f 100644 --- a/decort/controller.go +++ b/decort/controller.go @@ -27,7 +27,6 @@ package decort import ( "bytes" "crypto/tls" - "errors" "fmt" "io/ioutil" "net/http" @@ -379,13 +378,15 @@ func (config *ControllerCfg) decortAPICall(method string, api_name string, url_v req.Header.Set("Authorization", fmt.Sprintf("bearer %s", config.jwt)) } + var resp *http.Response + var body []byte for i := 0; i < 5; i++ { - resp, err := config.cc_client.Do(req) + resp, err = config.cc_client.Do(req) if err != nil { return "", err } - body, err := ioutil.ReadAll(resp.Body) + body, err = ioutil.ReadAll(resp.Body) if err != nil { return "", err } @@ -405,5 +406,6 @@ func (config *ControllerCfg) decortAPICall(method string, api_name string, url_v } } - return "", errors.New("number of retries exceeded") + return "", fmt.Errorf("decortAPICall: unexpected status code %d when calling API %q with request Body %q. Respone:\n%s", + resp.StatusCode, req.URL, params_str, body) }