Combine error checks in handleAccountInfo

This commit is contained in:
Pancakes 2025-04-25 19:27:52 -04:00
parent 21209ef4a7
commit e48b092de4
No known key found for this signature in database
GPG Key ID: 5792877BFA27DC8F

View File

@ -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)
}