0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-22 11:24:17 +01:00

api.Context.NotFound(...) should tolerate nil (#11288)

There is an unfortunate signature change with the api.Context
NotFound function; whereas the normal modules/context/Context
NotFound function requires an error or nil, the api.Context
variant will panic with an NPE if a nil is provided.

This PR will allow api.Context.NotFound to tolerate a being
passed a nil.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
zeripath 2020-05-05 19:52:13 +01:00 committed by GitHub
parent 0396fcf4b5
commit d9de58beee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -212,6 +212,11 @@ func (ctx *APIContext) NotFound(objs ...interface{}) {
var message = "Not Found"
var errors []string
for _, obj := range objs {
// Ignore nil
if obj == nil {
continue
}
if err, ok := obj.(error); ok {
errors = append(errors, err.Error())
} else {