summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/pull.go
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2017-11-04 11:10:01 -0700
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-11-04 19:10:01 +0100
commitd91fe5254da3d7137a139fd393b4bd2070e18b78 (patch)
treefd78aae7dff92b02281b80ce81bb0a12cdf542d9 /routers/api/v1/repo/pull.go
parent57de1ff991a864c8adf669e3919247c555e7a75a (diff)
downloadgitea-d91fe5254da3d7137a139fd393b4bd2070e18b78.tar.gz
gitea-d91fe5254da3d7137a139fd393b4bd2070e18b78.zip
Fix ignored errors in API route (#2850)
* Fix ignored errors in API route
Diffstat (limited to 'routers/api/v1/repo/pull.go')
-rw-r--r--routers/api/v1/repo/pull.go34
1 files changed, 24 insertions, 10 deletions
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index 9a38d37528..d1b73c6cf7 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -26,10 +26,6 @@ func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions)
MilestoneID: ctx.QueryInt64("milestone"),
})
- /*prs, maxResults, err := models.PullRequests(ctx.Repo.Repository.ID, &models.PullRequestsOptions{
- Page: form.Page,
- State: form.State,
- })*/
if err != nil {
ctx.Error(500, "PullRequests", err)
return
@@ -37,10 +33,22 @@ func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions)
apiPrs := make([]*api.PullRequest, len(prs))
for i := range prs {
- prs[i].LoadIssue()
- prs[i].LoadAttributes()
- prs[i].GetBaseRepo()
- prs[i].GetHeadRepo()
+ if err = prs[i].LoadIssue(); err != nil {
+ ctx.Error(500, "LoadIssue", err)
+ return
+ }
+ if err = prs[i].LoadAttributes(); err != nil {
+ ctx.Error(500, "LoadAttributes", err)
+ return
+ }
+ if err = prs[i].GetBaseRepo(); err != nil {
+ ctx.Error(500, "GetBaseRepo", err)
+ return
+ }
+ if err = prs[i].GetHeadRepo(); err != nil {
+ ctx.Error(500, "GetHeadRepo", err)
+ return
+ }
apiPrs[i] = prs[i].APIFormat()
}
@@ -60,8 +68,14 @@ func GetPullRequest(ctx *context.APIContext) {
return
}
- pr.GetBaseRepo()
- pr.GetHeadRepo()
+ if err = pr.GetBaseRepo(); err != nil {
+ ctx.Error(500, "GetBaseRepo", err)
+ return
+ }
+ if err = pr.GetHeadRepo(); err != nil {
+ ctx.Error(500, "GetHeadRepo", err)
+ return
+ }
ctx.JSON(200, pr.APIFormat())
}