Skip to content

Commit

Permalink
BUGFIX: judge nil pointer stored in error interface
Browse files Browse the repository at this point in the history
  • Loading branch information
FMLS committed Sep 25, 2020
1 parent 404189c commit a5cead4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions error.go
Expand Up @@ -21,9 +21,9 @@
package zap

import (
"sync"

"go.uber.org/zap/zapcore"
"reflect"
"sync"
)

var _errArrayElemPool = sync.Pool{New: func() interface{} {
Expand All @@ -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}
Expand Down

0 comments on commit a5cead4

Please sign in to comment.