Skip to content

Commit 40f80a1

Browse files
authored
Merge pull request #3 from gregwebs/tidb-docs-2
documentation for changes
2 parents f295249 + f879a1f commit 40f80a1

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

errors.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@
1313
//
1414
// Adding context to an error
1515
//
16-
// The errors.Wrap function returns a new error that adds context to the
17-
// original error by recording a stack trace at the point Wrap is called,
16+
// The errors.Annotate function returns a new error that adds context to the
17+
// original error by recording a stack trace at the point Annotate is called,
1818
// and the supplied message. For example
1919
//
2020
// _, err := ioutil.ReadAll(r)
2121
// if err != nil {
22-
// return errors.Wrap(err, "read failed")
22+
// return errors.Annotate(err, "read failed")
2323
// }
2424
//
25-
// If additional control is required the errors.WithStack and errors.WithMessage
26-
// functions destructure errors.Wrap into its component operations of annotating
25+
// If additional control is required the errors.AddStack and errors.WithMessage
26+
// functions destructure errors.Annotate into its component operations of annotating
2727
// an error with a stack trace and an a message, respectively.
2828
//
2929
// Retrieving the cause of an error
3030
//
31-
// Using errors.Wrap constructs a stack of errors, adding context to the
31+
// Using errors.Annotate constructs a stack of errors, adding context to the
3232
// preceding error. Depending on the nature of the error it may be necessary
33-
// to reverse the operation of errors.Wrap to retrieve the original error
33+
// to reverse the operation of errors.Annotate to retrieve the original error
3434
// for inspection. Any error value which implements this interface
3535
//
3636
// type causer interface {
@@ -50,6 +50,7 @@
5050
//
5151
// causer interface is not exported by this package, but is considered a part
5252
// of stable public API.
53+
// errors.Unwrap is also available: this will retrieve the next error in the chain.
5354
//
5455
// Formatted printing of errors
5556
//
@@ -64,7 +65,7 @@
6465
//
6566
// Retrieving the stack trace of an error or wrapper
6667
//
67-
// New, Errorf, Wrap, and Wrapf record a stack trace at the point they are invoked.
68+
// New, Errorf, Annotate, and Annotatef record a stack trace at the point they are invoked.
6869
// This information can be retrieved with the StackTracer interface that returns
6970
// a StackTrace. Where errors.StackTrace is defined as
7071
//
@@ -81,6 +82,8 @@
8182
// }
8283
//
8384
// See the documentation for Frame.Format for more details.
85+
//
86+
// errors.Find can be used to search for an error in the error chain.
8487
package errors
8588

8689
import (
@@ -148,6 +151,8 @@ func (f *fundamental) Format(s fmt.State, verb rune) {
148151

149152
// WithStack annotates err with a stack trace at the point WithStack was called.
150153
// If err is nil, WithStack returns nil.
154+
//
155+
// Deprecated: use AddStack
151156
func WithStack(err error) error {
152157
if err == nil {
153158
return nil
@@ -317,7 +322,8 @@ func Unwrap(err error) error {
317322
return nil
318323
}
319324

320-
// Find an error in the chain that matches a test function
325+
// Find an error in the chain that matches a test function.
326+
// returns nil if no error is found.
321327
func Find(origErr error, test func(error) bool) error {
322328
var foundErr error
323329
WalkDeep(origErr, func(err error) bool {

0 commit comments

Comments
 (0)