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

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

Loading…
Cancel
Save