From 7ec3660a091042cf572c2b7f036daf6659a7085f Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Thu, 6 Jul 2017 14:45:23 +0100 Subject: [PATCH] Add some errors --- 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" {