From 666bd1b9d1e50fbe963dfa93616317784be6ba6c Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Sat, 8 Feb 2020 14:46:05 -0500 Subject: [PATCH] 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 --- admin.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/admin.go b/admin.go index 0a73a11..83dcc80 100644 --- a/admin.go +++ b/admin.go @@ -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)