File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -403,6 +403,33 @@ func (c *Client) sendRequest(request *request) (*http.Response, error) {
403403 resp .StatusCode ,
404404 stringMessage ,
405405 )
406+
407+ var errorMessage map [string ]interface {} // Decode JSON body to handle issue
408+ err = json .NewDecoder (resp .Body ).Decode (& errorMessage )
409+
410+ if err != nil {
411+ _ , derr := httputil .DumpResponse (resp , true )
412+ if derr != nil {
413+ log .Printf (
414+ "[ERROR] Error dumping response body for '%s' request to '%s': %s" ,
415+ request .Method ,
416+ request .Endpoint ,
417+ derr ,
418+ )
419+ return nil , derr
420+ }
421+ uerr := errors .New (
422+ fmt .Sprintf (
423+ "%d - Unknown error connecting to Keyfactor %s, please check your connection." ,
424+ resp .StatusCode ,
425+ endpoint ,
426+ ),
427+ )
428+ log .Printf ("[ERROR] %s" , uerr )
429+ return nil , uerr
430+ }
431+
432+ stringMessage = fmt .Sprintf ("%v" , errorMessage ["Message" ])
406433 return nil , errors .New (stringMessage )
407434 } else if resp .StatusCode == http .StatusUnauthorized {
408435 dmp , derr := httputil .DumpResponse (resp , true )
You can’t perform that action at this time.
0 commit comments