... | ... |
@@ -295,7 +295,8 @@ func postImagesCreate(srv *Server, version float64, w http.ResponseWriter, r *ht |
295 | 295 |
w.Header().Set("Content-Type", "application/json") |
296 | 296 |
} |
297 | 297 |
if err := srv.ImagePull(image, tag, registry, w, version > 1.0); err != nil { |
298 |
- return err |
|
298 |
+ fmt.Fprintf(w, utils.FormatError(err.Error(), version > 1.0)) |
|
299 |
+ return nil |
|
299 | 300 |
} |
300 | 301 |
} else { //import |
301 | 302 |
if err := srv.ImageImport(src, repo, tag, r.Body, w); err != nil { |
... | ... |
@@ -1261,6 +1261,7 @@ func (cli *DockerCli) stream(method, path string, in io.Reader, out io.Writer) e |
1261 | 1261 |
type Message struct { |
1262 | 1262 |
Status string `json:"status,omitempty"` |
1263 | 1263 |
Progress string `json:"progress,omitempty"` |
1264 |
+ Error string `json:"error,omitempty"` |
|
1264 | 1265 |
} |
1265 | 1266 |
dec := json.NewDecoder(resp.Body) |
1266 | 1267 |
for { |
... | ... |
@@ -1272,6 +1273,8 @@ func (cli *DockerCli) stream(method, path string, in io.Reader, out io.Writer) e |
1272 | 1272 |
} |
1273 | 1273 |
if m.Progress != "" { |
1274 | 1274 |
fmt.Fprintf(out, "Downloading %s\r", m.Progress) |
1275 |
+ } else if m.Error != "" { |
|
1276 |
+ return fmt.Errorf(m.Error) |
|
1275 | 1277 |
} else { |
1276 | 1278 |
fmt.Fprintf(out, "%s\n", m.Status) |
1277 | 1279 |
} |
... | ... |
@@ -564,6 +564,13 @@ func FormatStatus(str string, json bool) string { |
564 | 564 |
return str + "\r\n" |
565 | 565 |
} |
566 | 566 |
|
567 |
+func FormatError(str string, json bool) string { |
|
568 |
+ if json { |
|
569 |
+ return "{\"error\" : \"" + str + "\"}" |
|
570 |
+ } |
|
571 |
+ return "Error: " + str + "\r\n" |
|
572 |
+} |
|
573 |
+ |
|
567 | 574 |
func FormatProgress(str string, json bool) string { |
568 | 575 |
if json { |
569 | 576 |
return "{\"progress\" : \"" + str + "\"}" |