mirror of
https://github.com/pkg/errors.git
synced 2025-05-31 11:42:45 +00:00
address spelling mistakes. Thanks @seh
This commit is contained in:
parent
6526c1c7e1
commit
cd6e0b425d
@ -19,17 +19,17 @@ if err != nil {
|
||||
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
|
||||
|
||||
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 {
|
||||
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) {
|
||||
case *MyError:
|
||||
|
@ -28,16 +28,16 @@
|
||||
//
|
||||
// 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 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
|
||||
//
|
||||
// type causer interface {
|
||||
// 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:
|
||||
// can be inspected by errors.Cause. 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) {
|
||||
// case *MyError:
|
||||
|
Loading…
x
Reference in New Issue
Block a user