1414// Adding context to an error
1515//
1616// The errors.Wrap function returns a new error that adds context to the
17- // original error. For example
17+ // original error by recording a stack trace at the point Wrap is called,
18+ // and the supplied message. For example
1819//
1920// _, err := ioutil.ReadAll(r)
2021// if err != nil {
2122// return errors.Wrap(err, "read failed")
2223// }
2324//
25+ // If additional control is required the errors.WithStack and errors.WithMessage
26+ // functions destructure errors.Wrap into its component operations of annotating
27+ // an error with a stack trace and an a message, respectively.
28+ //
2429// Retrieving the cause of an error
2530//
2631// Using errors.Wrap constructs a stack of errors, adding context to the
@@ -169,7 +174,8 @@ func (w *withStack) Format(s fmt.State, verb rune) {
169174 }
170175}
171176
172- // Wrap returns an error annotating err with message.
177+ // Wrap returns an error annotating err with a stack trace
178+ // at the point Wrap is called, and the supplied message.
173179// If err is nil, Wrap returns nil.
174180func Wrap (err error , message string ) error {
175181 if err == nil {
@@ -185,7 +191,8 @@ func Wrap(err error, message string) error {
185191 }
186192}
187193
188- // Wrapf returns an error annotating err with the format specifier.
194+ // Wrapf returns an error annotating err with a stack trace
195+ // at the point Wrapf is call, and the format specifier.
189196// If err is nil, Wrapf returns nil.
190197func Wrapf (err error , format string , args ... interface {}) error {
191198 if err == nil {
0 commit comments