commenter_get.go: ret error on non-existant user

This commit is contained in:
Adhityaa 2018-06-06 22:21:31 +05:30
parent d4f617a703
commit 16e3c926fe
2 changed files with 7 additions and 2 deletions

View File

@ -16,8 +16,8 @@ func commenterGetByHex(commenterHex string) (commenter, error) {
c := commenter{} c := commenter{}
if err := row.Scan(&c.CommenterHex, &c.Email, &c.Name, &c.Link, &c.Photo, &c.Provider, &c.JoinDate); err != nil { if err := row.Scan(&c.CommenterHex, &c.Email, &c.Name, &c.Link, &c.Photo, &c.Provider, &c.JoinDate); err != nil {
logger.Errorf("error scanning commenter: %v", err) // TODO: is this the only error?
return commenter{}, errorInternal return commenter{}, errorNoSuchCommenter
} }
return c, nil return c, nil
@ -41,5 +41,9 @@ func commenterGetBySession(session string) (commenter, error) {
return commenter{}, errorNoSuchSession return commenter{}, errorNoSuchSession
} }
if commenterHex == "none" {
return commenter{}, errorNoSuchSession
}
return commenterGetByHex(commenterHex) return commenterGetByHex(commenterHex)
} }

View File

@ -18,6 +18,7 @@ var errorNoSuchResetToken = errors.New("This password reset link has expired.")
var errorNotAuthorised = errors.New("You're not authorised to access that.") var errorNotAuthorised = errors.New("You're not authorised to access that.")
var errorEmailAlreadyExists = errors.New("That email address has already been registered.") var errorEmailAlreadyExists = errors.New("That email address has already been registered.")
var errorNoSuchSession = errors.New("No such session/state.") var errorNoSuchSession = errors.New("No such session/state.")
var errorNoSuchCommenter = errors.New("No such commenter.")
var errorAlreadyUpvoted = errors.New("You have already upvoted that comment.") var errorAlreadyUpvoted = errors.New("You have already upvoted that comment.")
var errorNoSuchDomain = errors.New("This domain is not registered with Commento.") var errorNoSuchDomain = errors.New("This domain is not registered with Commento.")
var errorNoSuchComment = errors.New("No such comment.") var errorNoSuchComment = errors.New("No such comment.")