|
6 | 6 | // return err
|
7 | 7 | // }
|
8 | 8 | //
|
9 |
| -// which applied recursively up the call stack results in error reports |
| 9 | +// which when applied recursively up the call stack results in error reports |
10 | 10 | // without context or debugging information. The errors package allows
|
11 | 11 | // programmers to add context to the failure path in their code in a way
|
12 | 12 | // that does not destroy the original value of the error.
|
|
15 | 15 | //
|
16 | 16 | // The errors.Wrap function returns a new error that adds context to the
|
17 | 17 | // original error by recording a stack trace at the point Wrap is called,
|
18 |
| -// and the supplied message. For example |
| 18 | +// together with the supplied message. For example |
19 | 19 | //
|
20 | 20 | // _, err := ioutil.ReadAll(r)
|
21 | 21 | // if err != nil {
|
22 | 22 | // return errors.Wrap(err, "read failed")
|
23 | 23 | // }
|
24 | 24 | //
|
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. |
| 25 | +// If additional control is required, the errors.WithStack and |
| 26 | +// errors.WithMessage functions destructure errors.Wrap into its component |
| 27 | +// operations: annotating an error with a stack trace and with a message, |
| 28 | +// respectively. |
28 | 29 | //
|
29 | 30 | // Retrieving the cause of an error
|
30 | 31 | //
|
|
38 | 39 | // }
|
39 | 40 | //
|
40 | 41 | // can be inspected by errors.Cause. errors.Cause will recursively retrieve
|
41 |
| -// the topmost error which does not implement causer, which is assumed to be |
| 42 | +// the topmost error that does not implement causer, which is assumed to be |
42 | 43 | // the original cause. For example:
|
43 | 44 | //
|
44 | 45 | // switch err := errors.Cause(err).(type) {
|
|
48 | 49 | // // unknown error
|
49 | 50 | // }
|
50 | 51 | //
|
51 |
| -// causer interface is not exported by this package, but is considered a part |
52 |
| -// of stable public API. |
| 52 | +// Although the causer interface is not exported by this package, it is |
| 53 | +// considered a part of its stable public interface. |
53 | 54 | //
|
54 | 55 | // Formatted printing of errors
|
55 | 56 | //
|
56 | 57 | // All error values returned from this package implement fmt.Formatter and can
|
57 |
| -// be formatted by the fmt package. The following verbs are supported |
| 58 | +// be formatted by the fmt package. The following verbs are supported: |
58 | 59 | //
|
59 | 60 | // %s print the error. If the error has a Cause it will be
|
60 |
| -// printed recursively |
| 61 | +// printed recursively. |
61 | 62 | // %v see %s
|
62 | 63 | // %+v extended format. Each Frame of the error's StackTrace will
|
63 | 64 | // be printed in detail.
|
64 | 65 | //
|
65 | 66 | // Retrieving the stack trace of an error or wrapper
|
66 | 67 | //
|
67 | 68 | // New, Errorf, Wrap, and Wrapf record a stack trace at the point they are
|
68 |
| -// invoked. This information can be retrieved with the following interface. |
| 69 | +// invoked. This information can be retrieved with the following interface: |
69 | 70 | //
|
70 | 71 | // type stackTracer interface {
|
71 | 72 | // StackTrace() errors.StackTrace
|
72 | 73 | // }
|
73 | 74 | //
|
74 |
| -// Where errors.StackTrace is defined as |
| 75 | +// The returned errors.StackTrace type is defined as |
75 | 76 | //
|
76 | 77 | // type StackTrace []Frame
|
77 | 78 | //
|
|
85 | 86 | // }
|
86 | 87 | // }
|
87 | 88 | //
|
88 |
| -// stackTracer interface is not exported by this package, but is considered a part |
89 |
| -// of stable public API. |
| 89 | +// Although the stackTracer interface is not exported by this package, it is |
| 90 | +// considered a part of its stable public interface. |
90 | 91 | //
|
91 | 92 | // See the documentation for Frame.Format for more details.
|
92 | 93 | package errors
|
|
0 commit comments