Wrap changes the Cause of the error. The location of the Wrap call is also stored in the error stack. For example: if err := SomeFunc(); err != nil { newErr := &packageError{"more context", private_value} return errors.Wrap(err, newErr) }
(other, newDescriptive error)
| 141 | // } |
| 142 | // |
| 143 | func Wrap(other, newDescriptive error) error { |
| 144 | err := &Err{ |
| 145 | previous: other, |
| 146 | cause: newDescriptive, |
| 147 | } |
| 148 | err.SetLocation(1) |
| 149 | return err |
| 150 | } |
| 151 | |
| 152 | // Wrapf changes the Cause of the error, and adds an annotation. The location |
| 153 | // of the Wrap call is also stored in the error stack. |
searching dependent graphs…