浏览代码

Merge branch 'master' of ssh://github.com/dotcloud/docker

Solomon Hykes 12 年之前
父节点
当前提交
be15d5f2d9
共有 1 个文件被更改,包括 13 次插入4 次删除
  1. 13 4
      commands.go

+ 13 - 4
commands.go

@@ -218,7 +218,10 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
 		if err != nil {
 		if err != nil {
 			return err
 			return err
 		}
 		}
-		return fmt.Errorf("error: %s", body)
+		if len(body) == 0 {
+			return fmt.Errorf("Error: %s", http.StatusText(resp.StatusCode))
+		}
+		return fmt.Errorf("Error: %s", body)
 	}
 	}
 
 
 	// Output the result
 	// Output the result
@@ -561,7 +564,7 @@ func (cli *DockerCli) CmdPort(args ...string) error {
 	if frontend, exists := out.NetworkSettings.PortMapping[cmd.Arg(1)]; exists {
 	if frontend, exists := out.NetworkSettings.PortMapping[cmd.Arg(1)]; exists {
 		fmt.Println(frontend)
 		fmt.Println(frontend)
 	} else {
 	} else {
-		return fmt.Errorf("error: No private port '%s' allocated on %s", cmd.Arg(1), cmd.Arg(0))
+		return fmt.Errorf("Error: No private port '%s' allocated on %s", cmd.Arg(1), cmd.Arg(0))
 	}
 	}
 	return nil
 	return nil
 }
 }
@@ -1335,7 +1338,10 @@ func (cli *DockerCli) call(method, path string, data interface{}) ([]byte, int,
 		return nil, -1, err
 		return nil, -1, err
 	}
 	}
 	if resp.StatusCode < 200 || resp.StatusCode >= 400 {
 	if resp.StatusCode < 200 || resp.StatusCode >= 400 {
-		return nil, resp.StatusCode, fmt.Errorf("error: %s", body)
+		if len(body) == 0 {
+			return nil, resp.StatusCode, fmt.Errorf("Error: %s", http.StatusText(resp.StatusCode))
+		}
+		return nil, resp.StatusCode, fmt.Errorf("Error: %s", body)
 	}
 	}
 	return body, resp.StatusCode, nil
 	return body, resp.StatusCode, nil
 }
 }
@@ -1365,7 +1371,10 @@ func (cli *DockerCli) stream(method, path string, in io.Reader, out io.Writer) e
 		if err != nil {
 		if err != nil {
 			return err
 			return err
 		}
 		}
-		return fmt.Errorf("error: %s", body)
+		if len(body) == 0 {
+			return fmt.Errorf("Error :%s", http.StatusText(resp.StatusCode))
+		}
+		return fmt.Errorf("Error: %s", body)
 	}
 	}
 
 
 	if resp.Header.Get("Content-Type") == "application/json" {
 	if resp.Header.Get("Content-Type") == "application/json" {