From e48b092de43f1bc99d9eb18bcb40f4dceb358227 Mon Sep 17 00:00:00 2001 From: Pancakes Date: Fri, 25 Apr 2025 19:27:52 -0400 Subject: [PATCH] Combine error checks in handleAccountInfo --- api/endpoints.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/api/endpoints.go b/api/endpoints.go index 5a51552..5d27443 100644 --- a/api/endpoints.go +++ b/api/endpoints.go @@ -56,18 +56,14 @@ func handleAccountInfo(w http.ResponseWriter, r *http.Request) { return } discordId, err := db.FetchDiscordIdByUsername(username) - if err != nil { - if !errors.Is(err, sql.ErrNoRows) { - httpError(w, r, err, http.StatusInternalServerError) - return - } + if err != nil && !errors.Is(err, sql.ErrNoRows) { + httpError(w, r, err, http.StatusInternalServerError) + return } googleId, err := db.FetchGoogleIdByUsername(username) - if err != nil { - if !errors.Is(err, sql.ErrNoRows) { - httpError(w, r, err, http.StatusInternalServerError) - return - } + if err != nil && !errors.Is(err, sql.ErrNoRows) { + httpError(w, r, err, http.StatusInternalServerError) + return } var hasAdminRole bool @@ -80,6 +76,7 @@ func handleAccountInfo(w http.ResponseWriter, r *http.Request) { httpError(w, r, err, http.StatusInternalServerError) return } + writeJSON(w, r, response) }