Return 400 instead of 500 when deleting or showing something where the id is not an int
the build failed
Details
the build failed
Details
This commit is contained in:
parent
989ab530dd
commit
56a3215147
|
@ -18,7 +18,7 @@ func AuthorShow(c echo.Context) error {
|
||||||
// Make int
|
// Make int
|
||||||
authorID, err := strconv.ParseInt(author, 10, 64)
|
authorID, err := strconv.ParseInt(author, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, models.Message{"Error getting author infos."})
|
return c.JSON(http.StatusBadRequest, models.Message{"Author ID is invalid."})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Author Infos
|
// Get Author Infos
|
||||||
|
|
|
@ -17,6 +17,9 @@ func BookShow(c echo.Context) error {
|
||||||
|
|
||||||
// Make int
|
// Make int
|
||||||
bookID, err := strconv.ParseInt(book, 10, 64)
|
bookID, err := strconv.ParseInt(book, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return c.JSON(http.StatusBadRequest, models.Message{"Book ID is invalid."})
|
||||||
|
}
|
||||||
|
|
||||||
// Get book infos
|
// Get book infos
|
||||||
bookInfo, exists, err := models.GetBookByID(bookID)
|
bookInfo, exists, err := models.GetBookByID(bookID)
|
||||||
|
|
|
@ -18,7 +18,7 @@ func ItemShow(c echo.Context) error {
|
||||||
// Make int
|
// Make int
|
||||||
itemID, err := strconv.ParseInt(item, 10, 64)
|
itemID, err := strconv.ParseInt(item, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, models.Message{"Error getting item infos."})
|
return c.JSON(http.StatusBadRequest, models.Message{"Item ID is invalid."})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get item Infos
|
// Get item Infos
|
||||||
|
|
|
@ -18,7 +18,7 @@ func PublisherShow(c echo.Context) error {
|
||||||
// Make int
|
// Make int
|
||||||
publisherID, err := strconv.ParseInt(publisher, 10, 64)
|
publisherID, err := strconv.ParseInt(publisher, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, models.Message{"Error getting publisher infos."})
|
return c.JSON(http.StatusBadRequest, models.Message{"Publisher ID is invalid."})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Publisher Infos
|
// Get Publisher Infos
|
||||||
|
|
|
@ -24,7 +24,7 @@ func UserShow(c echo.Context) error {
|
||||||
// Make int
|
// Make int
|
||||||
userID, err := strconv.ParseInt(user, 10, 64)
|
userID, err := strconv.ParseInt(user, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, models.Message{"Error getting user infos."})
|
return c.JSON(http.StatusBadRequest, models.Message{"User ID is invalid."})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get User Infos
|
// Get User Infos
|
||||||
|
|
|
@ -25,7 +25,7 @@ func UserChangePassword(c echo.Context) error {
|
||||||
// Make int
|
// Make int
|
||||||
userID, err := strconv.ParseInt(user, 10, 64)
|
userID, err := strconv.ParseInt(user, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, models.Message{"Error getting user infos."})
|
return c.JSON(http.StatusBadRequest, models.Message{"User ID is invalid."})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the user is admin or itself
|
// Check if the user is admin or itself
|
||||||
|
|
Loading…
Reference in New Issue