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

Method MarshalLogArray

error.go:53–72  ·  view source on GitHub ↗
(arr zapcore.ArrayEncoder)

Source from the content-addressed store, hash-verified

51type errArray []error
52
53func (errs errArray) MarshalLogArray(arr zapcore.ArrayEncoder) error {
54 for i := range errs {
55 if errs[i] == nil {
56 continue
57 }
58 // To represent each error as an object with an "error" attribute and
59 // potentially an "errorVerbose" attribute, we need to wrap it in a
60 // type that implements LogObjectMarshaler. To prevent this from
61 // allocating, pool the wrapper type.
62 elem := _errArrayElemPool.Get()
63 elem.error = errs[i]
64 err := arr.AppendObject(elem)
65 elem.error = nil
66 _errArrayElemPool.Put(elem)
67 if err != nil {
68 return err
69 }
70 }
71 return nil
72}
73
74type errArrayElem struct {
75 error

Callers

nothing calls this directly

Calls 3

PutMethod · 0.80
AppendObjectMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected