summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-03-08 17:46:24 +0000
committerGitHub <noreply@github.com>2020-03-08 14:46:24 -0300
commit33c5e5e7fa8ace0f8921b600736f126d752aa0ef (patch)
tree7cb22beccb57a054cd04d7c2103318264eda3d0e /routers
parent1966f421b38c5baef1023f3e4b089946d7af687f (diff)
downloadgitea-33c5e5e7fa8ace0f8921b600736f126d752aa0ef.tar.gz
gitea-33c5e5e7fa8ace0f8921b600736f126d752aa0ef.zip
Prevent panic in stopwatch (#10670)
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/issue_stopwatch.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/routers/api/v1/repo/issue_stopwatch.go b/routers/api/v1/repo/issue_stopwatch.go
index 01faa0d6b1..c8525e502c 100644
--- a/routers/api/v1/repo/issue_stopwatch.go
+++ b/routers/api/v1/repo/issue_stopwatch.go
@@ -5,6 +5,7 @@
package repo
import (
+ "errors"
"net/http"
"code.gitea.io/gitea/models"
@@ -173,19 +174,21 @@ func prepareIssueStopwatch(ctx *context.APIContext, shouldExist bool) (*models.I
if !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) {
ctx.Status(http.StatusForbidden)
- return nil, err
+ return nil, errors.New("Unable to write to PRs")
}
if !ctx.Repo.CanUseTimetracker(issue, ctx.User) {
ctx.Status(http.StatusForbidden)
- return nil, err
+ return nil, errors.New("Cannot use time tracker")
}
if models.StopwatchExists(ctx.User.ID, issue.ID) != shouldExist {
if shouldExist {
ctx.Error(http.StatusConflict, "StopwatchExists", "cannot stop/cancel a non existent stopwatch")
+ err = errors.New("cannot stop/cancel a non existent stopwatch")
} else {
ctx.Error(http.StatusConflict, "StopwatchExists", "cannot start a stopwatch again if it already exists")
+ err = errors.New("cannot start a stopwatch again if it already exists")
}
return nil, err
}