refactor errors.New to fmt.Errorf

This commit is contained in:
ari melody 2025-09-30 22:30:52 +01:00
parent ef655744bb
commit 419781988a
Signed by: ari
GPG key ID: CF99829C92678188
3 changed files with 10 additions and 13 deletions

View file

@ -2,7 +2,6 @@ package api
import (
"context"
"errors"
"fmt"
"net/http"
"os"
@ -173,7 +172,7 @@ func getSession(app *model.AppState, r *http.Request) (*model.Session, error) {
// check cookies first
sessionCookie, err := r.Cookie(model.COOKIE_TOKEN)
if err != nil && err != http.ErrNoCookie {
return nil, errors.New(fmt.Sprintf("Failed to retrieve session cookie: %v\n", err))
return nil, fmt.Errorf("Failed to retrieve session cookie: %v\n", err)
}
if sessionCookie != nil {
token = sessionCookie.Value
@ -188,7 +187,7 @@ func getSession(app *model.AppState, r *http.Request) (*model.Session, error) {
session, err := controller.GetSession(app.DB, token)
if err != nil && !strings.Contains(err.Error(), "no rows") {
return nil, errors.New(fmt.Sprintf("Failed to retrieve session: %v\n", err))
return nil, fmt.Errorf("Failed to retrieve session: %v\n", err)
}
if session != nil {