From d8028ed82353632a164dd73bd6e2df77f5c2f9bb Mon Sep 17 00:00:00 2001 From: "weiwei.danny" Date: Mon, 8 Jul 2024 12:35:19 +0800 Subject: [PATCH] fix: Return an error when the service response Unauthorized --- internal/utils/utils.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/utils/utils.go b/internal/utils/utils.go index db9850b..52d986a 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -76,6 +76,7 @@ func httpsPostWithRetryAndToken(reqBody []byte, debug bool, service string, name // try update token updateChan <- true } + return fmt.Errorf(fmt.Sprintf("http error code %d", httpRsp.StatusCode)) default: err = fmt.Errorf(fmt.Sprintf("http error code %d", httpRsp.StatusCode)) } @@ -148,7 +149,7 @@ func httpPostAndGetResponseWithRetry(reqBody []byte, debug bool, service string, err = fmt.Errorf(fmt.Sprintf("http error code %d", httpRsp.StatusCode)) } } - r := rand.Intn(10) + r := rand.Intn(60) + 20 time.Sleep(time.Duration(r) * time.Millisecond) }