Merge pull request #18462 from haoshuwei/modify-networkinspect-tocheckstatuscode

Modify docker network inspect client to check statusCode instead of s…
This commit is contained in:
Vincent Demeester 2015-12-07 12:48:41 +01:00
commit 6fcd33b576

View file

@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net"
"net/http"
"strings"
"text/tabwriter"
"text/template"
@ -224,9 +225,9 @@ func (cli *DockerCli) CmdNetworkInspect(args ...string) error {
var networks []types.NetworkResource
buf := new(bytes.Buffer)
for _, name := range cmd.Args() {
obj, _, err := readBody(cli.call("GET", "/networks/"+name, nil, nil))
obj, statusCode, err := readBody(cli.call("GET", "/networks/"+name, nil, nil))
if err != nil {
if strings.Contains(err.Error(), "not found") {
if statusCode == http.StatusNotFound {
fmt.Fprintf(cli.err, "Error: No such network: %s\n", name)
} else {
fmt.Fprintf(cli.err, "%s\n", err)