AnErr adds the field key with serialized err to the *Event context. If err is nil, no field is added.
(key string, err error)
| 420 | // AnErr adds the field key with serialized err to the *Event context. |
| 421 | // If err is nil, no field is added. |
| 422 | func (e *Event) AnErr(key string, err error) *Event { |
| 423 | if e == nil { |
| 424 | return e |
| 425 | } |
| 426 | switch m := ErrorMarshalFunc(err).(type) { |
| 427 | case nil: |
| 428 | return e |
| 429 | case LogObjectMarshaler: |
| 430 | return e.Object(key, m) |
| 431 | case error: |
| 432 | if isNilValue(m) { |
| 433 | return e |
| 434 | } |
| 435 | return e.Str(key, m.Error()) |
| 436 | case string: |
| 437 | return e.Str(key, m) |
| 438 | default: |
| 439 | return e.Interface(key, m) |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | // Errs adds the field key with errs as an array of serialized errors to the |
| 444 | // *Event context. |