소스 검색

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>
tags/v1.13.0-dev
zeripath 4 년 전
부모
커밋
d9de58beee
No account linked to committer's email address
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5
    0
      modules/context/api.go

+ 5
- 0
modules/context/api.go 파일 보기

@@ -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 {

Loading…
취소
저장