From 94d674fd4c2f5ff4c7230e2420a0f54438e35db5 Mon Sep 17 00:00:00 2001 From: JerryZhou Date: Mon, 20 Dec 2021 11:10:01 +0800 Subject: [PATCH] fix(cmd/proto-gen-errors): non nil assertion for error (#1700) --- cmd/protoc-gen-go-errors/template.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/protoc-gen-go-errors/template.go b/cmd/protoc-gen-go-errors/template.go index 1aa478810..3b6e0fc32 100644 --- a/cmd/protoc-gen-go-errors/template.go +++ b/cmd/protoc-gen-go-errors/template.go @@ -9,6 +9,9 @@ var errorsTemplate = ` {{ range .Errors }} func Is{{.CamelValue}}(err error) bool { + if err == nil { + return false + } e := errors.FromError(err) return e.Reason == {{.Name}}_{{.Value}}.String() && e.Code == {{.HTTPCode}} }