From e714cca47781db5547e052899d5bf8db24f73d84 Mon Sep 17 00:00:00 2001 From: Bennett Wetters Date: Sat, 25 Jul 2026 21:14:07 +0200 Subject: [PATCH] refactor(handlers): Use fmt.Errorf instead of errors.New(fmt.Sprintf()) --- handlers/util.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/handlers/util.go b/handlers/util.go index d7e6dd5..82af6fa 100644 --- a/handlers/util.go +++ b/handlers/util.go @@ -1,7 +1,6 @@ package handlers import ( - "errors" "fmt" "io" "net/http" @@ -20,14 +19,14 @@ func updateEndpointValidator( if !ok || !util.CheckCredentials(authDB, validCredentials, username, password) { w.Header().Set("WWW-Authenticate", "Basic realm=\"spaceapid\"") http.Error(w, "", http.StatusUnauthorized) - return []byte{}, errors.New(fmt.Sprintf("Unauthorized request from %s Username: %s Password: %s", r.RemoteAddr, username, password)) + return []byte{}, fmt.Errorf("Unauthorized request from %s Username: %s Password: %s", r.RemoteAddr, username, password) } // Read request body body, err := io.ReadAll(r.Body) if err != nil { http.Error(w, "", http.StatusInternalServerError) - return []byte{}, errors.New(fmt.Sprintf("Failed to read request body from %s with error: %s", r.RemoteAddr, err)) + return []byte{}, fmt.Errorf("Failed to read request body from %s with error: %s", r.RemoteAddr, err) } return body, nil