@@ -45,6 +45,8 @@ func PinIssue(ctx *context.APIContext) {
45
45
if err != nil {
46
46
if issues_model .IsErrIssueNotExist (err ) {
47
47
ctx .NotFound ()
48
+ } else if issues_model .IsErrIssueMaxPinReached (err ) {
49
+ ctx .Error (http .StatusBadRequest , "MaxPinReached" , err )
48
50
} else {
49
51
ctx .Error (http .StatusInternalServerError , "GetIssueByIndex" , err )
50
52
}
@@ -55,11 +57,13 @@ func PinIssue(ctx *context.APIContext) {
55
57
err = issue .LoadRepo (ctx )
56
58
if err != nil {
57
59
ctx .Error (http .StatusInternalServerError , "LoadRepo" , err )
60
+ return
58
61
}
59
62
60
63
err = issue .Pin (ctx , ctx .Doer )
61
64
if err != nil {
62
65
ctx .Error (http .StatusInternalServerError , "PinIssue" , err )
66
+ return
63
67
}
64
68
65
69
ctx .Status (http .StatusNoContent )
@@ -108,11 +112,13 @@ func UnpinIssue(ctx *context.APIContext) {
108
112
err = issue .LoadRepo (ctx )
109
113
if err != nil {
110
114
ctx .Error (http .StatusInternalServerError , "LoadRepo" , err )
115
+ return
111
116
}
112
117
113
118
err = issue .Unpin (ctx , ctx .Doer )
114
119
if err != nil {
115
120
ctx .Error (http .StatusInternalServerError , "UnpinIssue" , err )
121
+ return
116
122
}
117
123
118
124
ctx .Status (http .StatusNoContent )
@@ -166,6 +172,7 @@ func MoveIssuePin(ctx *context.APIContext) {
166
172
err = issue .MovePin (ctx , int (ctx .ParamsInt64 (":position" )))
167
173
if err != nil {
168
174
ctx .Error (http .StatusInternalServerError , "MovePin" , err )
175
+ return
169
176
}
170
177
171
178
ctx .Status (http .StatusNoContent )
@@ -193,12 +200,12 @@ func ListPinnedIssues(ctx *context.APIContext) {
193
200
// "200":
194
201
// "$ref": "#/responses/IssueList"
195
202
issues , err := issues_model .GetPinnedIssues (ctx , ctx .Repo .Repository .ID , false )
196
-
197
- if err == nil {
198
- ctx .JSON (http .StatusOK , convert .ToAPIIssueList (ctx , issues ))
199
- } else {
203
+ if err != nil {
200
204
ctx .Error (http .StatusInternalServerError , "LoadPinnedIssues" , err )
205
+ return
201
206
}
207
+
208
+ ctx .JSON (http .StatusOK , convert .ToAPIIssueList (ctx , issues ))
202
209
}
203
210
204
211
// ListPinnedPullRequests returns a list of all pinned PRs
@@ -225,6 +232,7 @@ func ListPinnedPullRequests(ctx *context.APIContext) {
225
232
issues , err := issues_model .GetPinnedIssues (ctx , ctx .Repo .Repository .ID , true )
226
233
if err != nil {
227
234
ctx .Error (http .StatusInternalServerError , "LoadPinnedPullRequests" , err )
235
+ return
228
236
}
229
237
230
238
apiPrs := make ([]* api.PullRequest , len (issues ))
0 commit comments