refactor errors.New to fmt.Errorf
This commit is contained in:
parent
ef655744bb
commit
419781988a
3 changed files with 10 additions and 13 deletions
|
@ -2,7 +2,6 @@ package controller
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
@ -19,7 +18,7 @@ const TOKEN_LEN = 64
|
|||
func GetSessionFromRequest(app *model.AppState, r *http.Request) (*model.Session, error) {
|
||||
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", err))
|
||||
return nil, fmt.Errorf("Failed to retrieve session cookie: %v", err)
|
||||
}
|
||||
|
||||
var session *model.Session
|
||||
|
@ -29,7 +28,7 @@ func GetSessionFromRequest(app *model.AppState, r *http.Request) (*model.Session
|
|||
session, err = GetSession(app.DB, sessionCookie.Value)
|
||||
|
||||
if err != nil && !strings.Contains(err.Error(), "no rows") {
|
||||
return nil, errors.New(fmt.Sprintf("Failed to retrieve session: %v", err))
|
||||
return nil, fmt.Errorf("Failed to retrieve session: %v", err)
|
||||
}
|
||||
|
||||
if session != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue