From fd79c57a5eaec659144fc7d667f70d5e835dd288 Mon Sep 17 00:00:00 2001 From: FMLS Date: Thu, 24 Sep 2020 17:32:47 +0800 Subject: [PATCH] BUGFIX: judge nil pointer stored in error interface --- error.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/error.go b/error.go index 65982a51e..ead80e5e3 100644 --- a/error.go +++ b/error.go @@ -22,7 +22,7 @@ package zap import ( "sync" - + "reflect" "go.uber.org/zap/zapcore" ) @@ -43,7 +43,7 @@ func Error(err error) Field { // For the common case in which the key is simply "error", the Error function // is shorter and less repetitive. func NamedError(key string, err error) Field { - if err == nil { + if err == nil || reflect.ValueOf(err).IsNil() { return Skip() } return Field{Key: key, Type: zapcore.ErrorType, Interface: err}