Return 400 instead of 500 when updateing something where the id is not an int

This commit is contained in:
kolaente 2018-01-29 15:46:56 +01:00 committed by kolaente
parent 80f86527ed
commit 989ab530dd
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
5 changed files with 5 additions and 5 deletions

View File

@ -41,7 +41,7 @@ func AuthorAddOrUpdate(c echo.Context) error {
authorID, err := strconv.ParseInt(id, 10, 64)
if err != nil {
return c.JSON(http.StatusInternalServerError, models.Message{"Could not get book id."})
return c.JSON(http.StatusBadRequest, models.Message{"Invalid ID."})
}
datAuthor.ID = authorID
}

View File

@ -36,7 +36,7 @@ func BookAddOrUpdate(c echo.Context) error {
bookID, err := strconv.ParseInt(id, 10, 64)
if err != nil {
return c.JSON(http.StatusInternalServerError, models.Message{"Could not get book id."})
return c.JSON(http.StatusBadRequest, models.Message{"Invalid ID."})
}
datBook.ID = bookID
}

View File

@ -36,7 +36,7 @@ func ItemAddOrUpdate(c echo.Context) error {
itemID, err := strconv.ParseInt(id, 10, 64)
if err != nil {
return c.JSON(http.StatusInternalServerError, models.Message{"Could not get item ID."})
return c.JSON(http.StatusBadRequest, models.Message{"Invalid ID."})
}
datItem.ID = itemID
}

View File

@ -37,7 +37,7 @@ func PublisherAddOrUpdate(c echo.Context) error {
publisherID, err := strconv.ParseInt(id, 10, 64)
if err != nil {
return c.JSON(http.StatusInternalServerError, models.Message{"Could not get item id."})
return c.JSON(http.StatusBadRequest, models.Message{"Invalid ID."})
}
datPublisher.ID = publisherID
}

View File

@ -43,7 +43,7 @@ func UserAddOrUpdate(c echo.Context) error {
userID, err := strconv.ParseInt(id, 10, 64)
if err != nil {
return c.JSON(http.StatusInternalServerError, models.Message{"Could not get item id."})
return c.JSON(http.StatusBadRequest, models.Message{"Invalid ID."})
}
datUser.ID = userID
}