From 299b58a75fe56cc43ebb54ebe83debe8f99cb539 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Thu, 6 Jul 2017 14:45:23 +0100 Subject: [PATCH] Add some errors Former-commit-id: 7f39ee9051d7c251799ac614f1c60a74a6920b35 [formerly 4b42e5f6094fb6fc68646a6c1f760fb3846ff775] [formerly 2899ccbafcab3fd9bbb6c9735b3b04253cc2811f [formerly 7ec3660a091042cf572c2b7f036daf6659a7085f]] Former-commit-id: 06b296ab039eaa34812506101a9932c02c4820a2 [formerly 015d1fafe773a8b6b4a055e9bc7ce47190852a5c] Former-commit-id: b599d9c07782168f31d4e606f7b5b157938c6e7c --- api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api.go b/api.go index ceb5fb0e..0bf2948e 100644 --- a/api.go +++ b/api.go @@ -215,7 +215,7 @@ func postPutHandler(c *requestContext, w http.ResponseWriter, r *http.Request) ( // if the file already exists. If so, we just return a 409 Conflict. if r.Method == http.MethodPost { if _, err := c.us.FileSystem.Stat(context.TODO(), r.URL.Path); err == nil { - return http.StatusConflict, nil + return http.StatusConflict, errors.New("There is already a file on that path") } } @@ -504,7 +504,7 @@ func usersPutHandler(c *requestContext, w http.ResponseWriter, r *http.Request) // If the request body is empty, send a Bad Request status. if r.Body == nil { - return http.StatusBadRequest, nil + return http.StatusBadRequest, errors.New("The request has an empty body") } var u User @@ -512,7 +512,7 @@ func usersPutHandler(c *requestContext, w http.ResponseWriter, r *http.Request) // Parses the user and checks for error. err = json.NewDecoder(r.Body).Decode(&u) if err != nil { - return http.StatusBadRequest, nil + return http.StatusBadRequest, errors.New("Invalid JSON") } if sid == "self" {