From cd13fe3cffa1052753a6d4c726701258c266ad72 Mon Sep 17 00:00:00 2001 From: maru Date: Fri, 24 May 2024 01:49:35 -0400 Subject: [PATCH] Use errors.Is everywhere --- api/account/login.go | 3 ++- api/endpoints.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/api/account/login.go b/api/account/login.go index bfd11be..5fc3e9c 100644 --- a/api/account/login.go +++ b/api/account/login.go @@ -22,6 +22,7 @@ import ( "crypto/rand" "database/sql" "encoding/base64" + "errors" "fmt" "github.com/pagefaultgames/rogueserver/db" @@ -43,7 +44,7 @@ func Login(username, password string) (LoginResponse, error) { key, salt, err := db.FetchAccountKeySaltFromUsername(username) if err != nil { - if err == sql.ErrNoRows { + if errors.Is(err, sql.ErrNoRows) { return response, fmt.Errorf("account doesn't exist") } diff --git a/api/endpoints.go b/api/endpoints.go index 9eb4809..88d3416 100644 --- a/api/endpoints.go +++ b/api/endpoints.go @@ -532,7 +532,7 @@ func legacyHandleSaveData(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case "/savedata/get": save, err = savedata.Get(uuid, datatype, slot) - if err == sql.ErrNoRows { + if errors.Is(err, sql.ErrNoRows) { http.Error(w, err.Error(), http.StatusNotFound) return }