From 9d0d13f217050402b0e3de10f6505b6d3927979a Mon Sep 17 00:00:00 2001 From: Hu Keping Date: Fri, 27 Mar 2015 23:17:50 +0800 Subject: [PATCH] Add nice error message Generally, when using Remote API to push images there needs a http Header X-Registry-Auth. For compatibility if there was no authConfig header, everything will be okay if a proper JSON-http-body was applied. But when both X-Registry-Auth Header and the Body are missing, due to the function of decode JSON, it will return an EOF error which was not very clear to user. So I think we can make the respone error be more nice. Signed-off-by: Hu Keping Upstream-commit: cee62a95a2086dace52f2492de781aa333abca3b Component: engine --- components/engine/api/server/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/engine/api/server/server.go b/components/engine/api/server/server.go index 2dabbbebad..ec90f7fb97 100644 --- a/components/engine/api/server/server.go +++ b/components/engine/api/server/server.go @@ -662,7 +662,7 @@ func postImagesPush(eng *engine.Engine, version version.Version, w http.Response } else { // the old format is supported for compatibility if there was no authConfig header if err := json.NewDecoder(r.Body).Decode(authConfig); err != nil { - return err + return fmt.Errorf("Bad parameters and missing X-Registry-Auth: %v", err) } }