From 693ff4d2ae5f0d723469340f67bb55f7aa3e824b Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Thu, 14 Nov 2013 23:53:43 +0000 Subject: [PATCH] Fix the brittle errorstring-to-httperror recognition code which in turn is required by autopull (the client issues a pull if container creation returns 404) --- api.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api.go b/api.go index c5a91de5b5..60c4d68327 100644 --- a/api.go +++ b/api.go @@ -61,7 +61,10 @@ func parseMultipartForm(r *http.Request) error { func httpError(w http.ResponseWriter, err error) { statusCode := http.StatusInternalServerError - if strings.HasPrefix(err.Error(), "No such") { + // FIXME: this is brittle and should not be necessary. + // If we need to differentiate between different possible error types, we should + // create appropriate error types with clearly defined meaning. + if strings.Contains(err.Error(), "No such") { statusCode = http.StatusNotFound } else if strings.HasPrefix(err.Error(), "Bad parameter") { statusCode = http.StatusBadRequest