Skip to content

Commit

Permalink
Use errors.Is everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
patapancakes committed May 24, 2024
1 parent 476e667 commit cd13fe3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion api/account/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"crypto/rand"
"database/sql"
"encoding/base64"
"errors"
"fmt"

"github.com/pagefaultgames/rogueserver/db"
Expand All @@ -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")
}

Expand Down
2 changes: 1 addition & 1 deletion api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit cd13fe3

Please sign in to comment.