Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Commit

Permalink
doc tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
davecheney committed Sep 29, 2016
1 parent 7433cb0 commit 645ef00
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@
// Adding context to an error
//
// The errors.Wrap function returns a new error that adds context to the
// original error. For example
// original error by recording a stack trace at the point Wrap is called,
// and the supplied message. For example
//
// _, err := ioutil.ReadAll(r)
// if err != nil {
// return errors.Wrap(err, "read failed")
// }
//
// If additional control is required the errors.WithStack and errors.WithMessage
// functions destructure errors.Wrap into its component operations of annotating
// an error with a stack trace and an a message, respectively.

This comment has been minimized.

Copy link
@seh

seh Sep 20, 2017

Contributor
  • s/an a/a/

This comment has been minimized.

Copy link
@davecheney

davecheney via email Sep 20, 2017

Author Member

This comment has been minimized.

Copy link
@seh

seh Sep 20, 2017

Contributor

See #135.

//
// Retrieving the cause of an error
//
// Using errors.Wrap constructs a stack of errors, adding context to the
Expand Down Expand Up @@ -169,7 +174,8 @@ func (w *withStack) Format(s fmt.State, verb rune) {
}
}

// Wrap returns an error annotating err with message.
// Wrap returns an error annotating err with a stack trace
// at the point Wrap is called, and the supplied message.
// If err is nil, Wrap returns nil.
func Wrap(err error, message string) error {
if err == nil {
Expand All @@ -185,7 +191,8 @@ func Wrap(err error, message string) error {
}
}

// Wrapf returns an error annotating err with the format specifier.
// Wrapf returns an error annotating err with a stack trace
// at the point Wrapf is call, and the format specifier.
// If err is nil, Wrapf returns nil.
func Wrapf(err error, format string, args ...interface{}) error {
if err == nil {
Expand Down

0 comments on commit 645ef00

Please sign in to comment.