WithError returns new fields that contain the passed error and all its fields (if any).
(err error)
| 111 | |
| 112 | // WithError returns new fields that contain the passed error and all its fields (if any). |
| 113 | func (f *F) WithError(err error) *F { |
| 114 | res := f.WithField("error", err) |
| 115 | |
| 116 | if fld, ok := err.(Fielder); ok { |
| 117 | return res.With(fld.Fields()) |
| 118 | } |
| 119 | |
| 120 | return res |
| 121 | } |