mirror of https://github.com/docker/docs.git
better error
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
6044354ea2
commit
bc17fbd6f7
11
api/api.go
11
api/api.go
|
|
@ -345,24 +345,25 @@ func deleteImages(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size := len(matchedImages)
|
if len(matchedImages) == 0 {
|
||||||
if size == 0 {
|
|
||||||
httpError(w, fmt.Sprintf("No such image %s", name), http.StatusNotFound)
|
httpError(w, fmt.Sprintf("No such image %s", name), http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
out := []*dockerclient.ImageDelete{}
|
out := []*dockerclient.ImageDelete{}
|
||||||
|
errs := []string{}
|
||||||
for _, image := range matchedImages {
|
for _, image := range matchedImages {
|
||||||
content, err := image.Node.DockerClient().RemoveImage(name)
|
content, err := image.Node.DockerClient().RemoveImage(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
out = nil
|
errs = append(errs, fmt.Sprintf("%s: %s", image.Node.Name(), err.Error()))
|
||||||
httpError(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
out = append(out, content...)
|
out = append(out, content...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if out != nil {
|
if len(errs) != 0 {
|
||||||
|
httpError(w, strings.Join(errs, ""), http.StatusInternalServerError)
|
||||||
|
} else {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(NewWriteFlusher(w)).Encode(out)
|
json.NewEncoder(NewWriteFlusher(w)).Encode(out)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue