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 24, 2020
1 parent 404189c commit fd79c57
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions error.go
Expand Up @@ -22,7 +22,7 @@ package zap

import (
"sync"

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

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 fd79c57

Please sign in to comment.