Show correct error when user not found in admin panel

Previously, it would show a 500. This also logs the real reason if it's
not a "not found" error
This commit is contained in:
Matt Baer 2020-02-08 14:46:05 -05:00
parent af14bcbb78
commit 666bd1b9d1

View file

@ -187,7 +187,11 @@ func handleViewAdminUser(app *App, u *User, w http.ResponseWriter, r *http.Reque
var err error
p.User, err = app.db.GetUserForAuth(username)
if err != nil {
return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not get user: %v", err)}
if err == ErrUserNotFound {
return err
}
log.Error("Could not get user: %v", err)
return impart.HTTPError{http.StatusInternalServerError, err.Error()}
}
flashes, _ := getSessionFlashes(app, w, r, nil)