From 16e3c926fe4ec1ce18f2cdf5057d27bc2fc77c56 Mon Sep 17 00:00:00 2001 From: Adhityaa Date: Wed, 6 Jun 2018 22:21:31 +0530 Subject: [PATCH] commenter_get.go: ret error on non-existant user --- api/commenter_get.go | 8 ++++++-- api/errors.go | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/api/commenter_get.go b/api/commenter_get.go index 9c6f8d6..5d59ac7 100644 --- a/api/commenter_get.go +++ b/api/commenter_get.go @@ -16,8 +16,8 @@ func commenterGetByHex(commenterHex string) (commenter, error) { c := commenter{} 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) - return commenter{}, errorInternal + // TODO: is this the only error? + return commenter{}, errorNoSuchCommenter } return c, nil @@ -41,5 +41,9 @@ func commenterGetBySession(session string) (commenter, error) { return commenter{}, errorNoSuchSession } + if commenterHex == "none" { + return commenter{}, errorNoSuchSession + } + return commenterGetByHex(commenterHex) } diff --git a/api/errors.go b/api/errors.go index d9a8d32..b8ba5bc 100644 --- a/api/errors.go +++ b/api/errors.go @@ -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 errorEmailAlreadyExists = errors.New("That email address has already been registered.") 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 errorNoSuchDomain = errors.New("This domain is not registered with Commento.") var errorNoSuchComment = errors.New("No such comment.")