浏览代码

Merge pull request #32 from shykes/shykes-0.6.5-dm-plugin

Merge bug fix from dotcloud/docker master
Michael Crosby 11 年之前
父节点
当前提交
0c38f86e5e
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      api.go

+ 4 - 1
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