Add some errors

Former-commit-id: 7f39ee9051d7c251799ac614f1c60a74a6920b35 [formerly 4b42e5f6094fb6fc68646a6c1f760fb3846ff775] [formerly 2899ccbafcab3fd9bbb6c9735b3b04253cc2811f [formerly 7ec3660a09]]
Former-commit-id: 06b296ab039eaa34812506101a9932c02c4820a2 [formerly 015d1fafe773a8b6b4a055e9bc7ce47190852a5c]
Former-commit-id: b599d9c07782168f31d4e606f7b5b157938c6e7c
pull/726/head
Henrique Dias 2017-07-06 14:45:23 +01:00
parent 0012601652
commit 299b58a75f
1 changed files with 3 additions and 3 deletions

6
api.go
View File

@ -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" {