fix error message in export

This commit is contained in:
Victor Vieux 2013-05-13 11:38:13 +02:00
parent 908e4797a6
commit 8b31d30601
2 changed files with 9 additions and 1 deletions

2
api.go
View file

@ -117,7 +117,7 @@ func getContainersExport(srv *Server, w http.ResponseWriter, r *http.Request, va
if err := srv.ContainerExport(name, w); err != nil {
Debugf("%s", err.Error())
//return nil, err
return err
}
return nil
}

View file

@ -1196,6 +1196,14 @@ func stream(method, path string) error {
return err
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode >= 400 {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
return fmt.Errorf("error: %s", body)
}
if _, err := io.Copy(os.Stdout, resp.Body); err != nil {
return err
}