From 8b31d30601f487bca5e4985c6a14b89e47ac83be Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Mon, 13 May 2013 11:38:13 +0200 Subject: [PATCH] fix error message in export --- api.go | 2 +- commands.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/api.go b/api.go index 2198a0963a..162dc66160 100644 --- a/api.go +++ b/api.go @@ -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 } diff --git a/commands.go b/commands.go index dc3f8c4e87..a8363925b2 100644 --- a/commands.go +++ b/commands.go @@ -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 }