Handle requests for non-existing users
This commit is contained in:
parent
8a7202ffd7
commit
2d70d013ce
|
@ -108,6 +108,10 @@ func getUser(c *gin.Context) {
|
|||
user := user{}
|
||||
err := db.QueryRow("SELECT id_alumno,nombre,apellido1,apellido2,email FROM alumnos WHERE id_alumno = "+id).Scan(&user.Id, &user.Name, &user.Surname1, &user.Surname2, &user.Email)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
c.String(http.StatusNotFound, "User not found")
|
||||
return
|
||||
}
|
||||
e := fmt.Sprintf("SOMETHING BAD HAPPENED QUERYING THE DATABASE: %v\n", err)
|
||||
log.Print(e)
|
||||
c.String(http.StatusInternalServerError, e)
|
||||
|
|
Loading…
Reference in New Issue