MCPcopy
hub / github.com/uber-go/zap / NamedError

Function NamedError

error.go:44–49  ·  view source on GitHub ↗

NamedError constructs a field that lazily stores err.Error() under the provided key. Errors which also implement fmt.Formatter (like those produced by github.com/pkg/errors) will also have their verbose representation stored under key+"Verbose". If passed a nil error, the field is a no-op. For the

(key string, err error)

Source from the content-addressed store, hash-verified

42// For the common case in which the key is simply "error", the Error function
43// is shorter and less repetitive.
44func NamedError(key string, err error) Field {
45 if err == nil {
46 return Skip()
47 }
48 return Field{Key: key, Type: zapcore.ErrorType, Interface: err}
49}
50
51type errArray []error
52

Callers 2

ErrorFunction · 0.85
TestErrorConstructorsFunction · 0.85

Calls 1

SkipFunction · 0.85

Tested by 1

TestErrorConstructorsFunction · 0.68