Use errors.Is everywhere

pull/23/head
maru 6 months ago
parent 476e667572
commit cd13fe3cff
No known key found for this signature in database
GPG Key ID: 37689350E9CD0F0D

@ -22,6 +22,7 @@ import (
"crypto/rand" "crypto/rand"
"database/sql" "database/sql"
"encoding/base64" "encoding/base64"
"errors"
"fmt" "fmt"
"github.com/pagefaultgames/rogueserver/db" "github.com/pagefaultgames/rogueserver/db"
@ -43,7 +44,7 @@ func Login(username, password string) (LoginResponse, error) {
key, salt, err := db.FetchAccountKeySaltFromUsername(username) key, salt, err := db.FetchAccountKeySaltFromUsername(username)
if err != nil { if err != nil {
if err == sql.ErrNoRows { if errors.Is(err, sql.ErrNoRows) {
return response, fmt.Errorf("account doesn't exist") return response, fmt.Errorf("account doesn't exist")
} }

@ -532,7 +532,7 @@ func legacyHandleSaveData(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path { switch r.URL.Path {
case "/savedata/get": case "/savedata/get":
save, err = savedata.Get(uuid, datatype, slot) save, err = savedata.Get(uuid, datatype, slot)
if err == sql.ErrNoRows { if errors.Is(err, sql.ErrNoRows) {
http.Error(w, err.Error(), http.StatusNotFound) http.Error(w, err.Error(), http.StatusNotFound)
return return
} }

Loading…
Cancel
Save