Ver código fonte

Merge pull request #4192 from crosbymichael/fix-404

Fix error message only if no body is retuned
unclejack 11 anos atrás
pai
commit
045462a367
1 arquivos alterados com 2 adições e 4 exclusões
  1. 2 4
      api/client.go

+ 2 - 4
api/client.go

@@ -2080,15 +2080,13 @@ func (cli *DockerCli) call(method, path string, data interface{}, passAuthInfo b
 		return nil, -1, err
 		return nil, -1, err
 	}
 	}
 
 
-	if resp.StatusCode == 404 {
-		return nil, resp.StatusCode, fmt.Errorf("Error: request for %s returned 404 Not Found for the api version", req.URL)
-	} else if resp.StatusCode < 200 || resp.StatusCode >= 400 {
+	if resp.StatusCode < 200 || resp.StatusCode >= 400 {
 		body, err := ioutil.ReadAll(resp.Body)
 		body, err := ioutil.ReadAll(resp.Body)
 		if err != nil {
 		if err != nil {
 			return nil, -1, err
 			return nil, -1, err
 		}
 		}
 		if len(body) == 0 {
 		if len(body) == 0 {
-			return nil, resp.StatusCode, fmt.Errorf("Error :%s", http.StatusText(resp.StatusCode))
+			return nil, resp.StatusCode, fmt.Errorf("Error: request returned %s for api route and version %s, check if the server supports the requested api version", http.StatusText(resp.StatusCode), req.URL)
 		}
 		}
 		return nil, resp.StatusCode, fmt.Errorf("Error: %s", bytes.TrimSpace(body))
 		return nil, resp.StatusCode, fmt.Errorf("Error: %s", bytes.TrimSpace(body))
 	}
 	}