diff --git a/error.go b/error.go index 65982a51e..c74b30487 100644 --- a/error.go +++ b/error.go @@ -21,9 +21,9 @@ package zap import ( - "sync" - "go.uber.org/zap/zapcore" + "reflect" + "sync" ) var _errArrayElemPool = sync.Pool{New: func() interface{} { @@ -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}