@@ -63,7 +63,7 @@ func createNewRequest(method, url string, body io.Reader, accessID string, acces
6363func logRequestAndResponse (req * http.Request , resp * http.Response ) {
6464 var maskedHeader = req .Header .Clone ()
6565 maskedHeader .Set ("Authorization" , "xxxxxxxxxxx" )
66- log .Printf ("[DEBUG] Request: [Method=%s] [URL=%s] [Headers=%s]. Response: [StatusCode =%s]\n " , req .Method , req .URL , maskedHeader , resp .Status )
66+ log .Printf ("[DEBUG] Request: [Method=%s] [URL=%s] [Headers=%s]. Response: [Status =%s]\n " , req .Method , req .URL , maskedHeader , resp .Status )
6767}
6868
6969func (s * Client ) PostWithCookies (urlPath string , payload interface {}) ([]byte , []* http.Cookie , error ) {
@@ -328,12 +328,17 @@ func (s *Client) Delete(urlPath string) ([]byte, error) {
328328 return d , nil
329329}
330330
331+ func ErrorHandler (resp * http.Response , err error , numTries int ) (* http.Response , error ) {
332+ log .Printf ("[ERROR] Request %s failed after %d attempts with response: [%s]" , resp .Request .URL , numTries , resp .Status )
333+ return resp , err
334+ }
335+
331336func NewClient (accessID , accessKey , authJwt , environment , base_url string , admin bool ) (* Client , error ) {
332337 retryClient := retryablehttp .NewClient ()
333338 retryClient .RetryMax = 10
334339 // Disable DEBUG logs (https://github.com/hashicorp/go-retryablehttp/issues/31)
335340 retryClient .Logger = nil
336-
341+ retryClient . ErrorHandler = ErrorHandler
337342 client := Client {
338343 AccessID : accessID ,
339344 AccessKey : accessKey ,
0 commit comments