address spelling mistakes. Thanks @seh

This commit is contained in:
Dave Cheney 2016-04-27 10:39:47 +10:00
parent 6526c1c7e1
commit cd6e0b425d
2 changed files with 7 additions and 7 deletions

View File

@ -19,17 +19,17 @@ if err != nil {
return errors.Wrap(err, "read failed") return errors.Wrap(err, "read failed")
} }
``` ```
In addition, errors.Wrap records the file and line where it was called, allowing the programmer to retrieve the path to the original error. In addition, `errors.Wrap` records the file and line where it was called, allowing the programmer to retrieve the path to the original error.
## Retrieving the cause of an error ## Retrieving the cause of an error
Using errors.Wrap constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to recurse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to recurse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`.
``` ```
type causer interface { type causer interface {
Cause() error Cause() error
} }
``` ```
Can be inspected by errors.Cause which will recursively retrieve the topmost error which does nor implement causer, which is assumed to be the original cause. For example: `errors.Cause` will recursively retrieve the topmost error which does nor implement causer, which is assumed to be the original cause. For example:
``` ```
switch err := errors.Cause(err).(type) { switch err := errors.Cause(err).(type) {
case *MyError: case *MyError:

View File

@ -28,16 +28,16 @@
// //
// Using errors.Wrap constructs a stack of errors, adding context to the // Using errors.Wrap constructs a stack of errors, adding context to the
// preceding error. Depending on the nature of the error it may be necessary // preceding error. Depending on the nature of the error it may be necessary
// to recerse the operation of errors.Wrap to retrieve the original error // to reverse the operation of errors.Wrap to retrieve the original error
// for inspection. Any error value which implements this interface // for inspection. Any error value which implements this interface
// //
// type causer interface { // type causer interface {
// Cause() error // Cause() error
// } // }
// //
// Can be inspected by errors.Cause which will recursively retrieve the topmost // can be inspected by errors.Cause. errors.Cause will recursively retrieve
// error which does nor implement causer, which is assumed to be the original // the topmost error which does nor implement causer, which is assumed to be
// cause. For example: // the original cause. For example:
// //
// switch err := errors.Cause(err).(type) { // switch err := errors.Cause(err).(type) {
// case *MyError: // case *MyError: