Return 400 instead of 500 when updateing something where the id is not an int
This commit is contained in:
parent
80f86527ed
commit
989ab530dd
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue