@@ -45,6 +45,8 @@ func PinIssue(ctx *context.APIContext) {
4545 if err != nil {
4646 if issues_model .IsErrIssueNotExist (err ) {
4747 ctx .NotFound ()
48+ } else if issues_model .IsErrIssueMaxPinReached (err ) {
49+ ctx .Error (http .StatusBadRequest , "MaxPinReached" , err )
4850 } else {
4951 ctx .Error (http .StatusInternalServerError , "GetIssueByIndex" , err )
5052 }
@@ -55,11 +57,13 @@ func PinIssue(ctx *context.APIContext) {
5557 err = issue .LoadRepo (ctx )
5658 if err != nil {
5759 ctx .Error (http .StatusInternalServerError , "LoadRepo" , err )
60+ return
5861 }
5962
6063 err = issue .Pin (ctx , ctx .Doer )
6164 if err != nil {
6265 ctx .Error (http .StatusInternalServerError , "PinIssue" , err )
66+ return
6367 }
6468
6569 ctx .Status (http .StatusNoContent )
@@ -108,11 +112,13 @@ func UnpinIssue(ctx *context.APIContext) {
108112 err = issue .LoadRepo (ctx )
109113 if err != nil {
110114 ctx .Error (http .StatusInternalServerError , "LoadRepo" , err )
115+ return
111116 }
112117
113118 err = issue .Unpin (ctx , ctx .Doer )
114119 if err != nil {
115120 ctx .Error (http .StatusInternalServerError , "UnpinIssue" , err )
121+ return
116122 }
117123
118124 ctx .Status (http .StatusNoContent )
@@ -166,6 +172,7 @@ func MoveIssuePin(ctx *context.APIContext) {
166172 err = issue .MovePin (ctx , int (ctx .ParamsInt64 (":position" )))
167173 if err != nil {
168174 ctx .Error (http .StatusInternalServerError , "MovePin" , err )
175+ return
169176 }
170177
171178 ctx .Status (http .StatusNoContent )
@@ -193,12 +200,12 @@ func ListPinnedIssues(ctx *context.APIContext) {
193200 // "200":
194201 // "$ref": "#/responses/IssueList"
195202 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 {
200204 ctx .Error (http .StatusInternalServerError , "LoadPinnedIssues" , err )
205+ return
201206 }
207+
208+ ctx .JSON (http .StatusOK , convert .ToAPIIssueList (ctx , issues ))
202209}
203210
204211// ListPinnedPullRequests returns a list of all pinned PRs
@@ -225,6 +232,7 @@ func ListPinnedPullRequests(ctx *context.APIContext) {
225232 issues , err := issues_model .GetPinnedIssues (ctx , ctx .Repo .Repository .ID , true )
226233 if err != nil {
227234 ctx .Error (http .StatusInternalServerError , "LoadPinnedPullRequests" , err )
235+ return
228236 }
229237
230238 apiPrs := make ([]* api.PullRequest , len (issues ))
0 commit comments