-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from dyweb/errors/init
[errors] Replace pkg/errors Fix #54 - multi error and wrap error - multi error `Append(err error)` returns true if it got a non nil error uber-go/multierr#21 - `Wrap` would reuse stack if the underlying error has one pkg/errors#122, and if `Frames()` is not called, `runtime.Frames` would not be expanded to `[]runtime.Frame`
- Loading branch information
Showing
68 changed files
with
1,032 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
// Package cast convert types safely and drop incompatible types during conversion | ||
// | ||
// it is inspired by https://github.com/spf13/cast | ||
package cast |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// gommon is the commandline util for generator | ||
package main | ||
|
||
import ( | ||
|
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// Package config supports go text/template, environment and self defined variables | ||
package config | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Errors | ||
|
||
A error package supports wrapping and multi error | ||
|
||
- init https://github.com/dyweb/gommon/issues/54 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Doc | ||
|
||
## Survey | ||
|
||
wrap | ||
|
||
- [pkg/errors](pkg-errors.md) | ||
- [juju/errgo](juju-errgo.md) | ||
- support `Mask`, which is not seen in other packages | ||
- [juju/errors](juju-errors.md) | ||
- same as errgo, and not depending on it, the description is [outdated](https://github.com/juju/errors/pull/10) | ||
- [hashicorp/errwrap](hashicorp-errwrap.md) | ||
- contains string or type | ||
- get error by string or type | ||
|
||
multi error | ||
|
||
- [hashicorp/go-multierror](hashicorp-go-multierror.md) | ||
- flatten multierror when append | ||
- ErrorOrNil | ||
- https://golang.org/doc/faq#nil_error Why is my nil error value not equal to nil? | ||
- [uber/multierr](uber-multierr.md) | ||
- combine more than one error | ||
- [x] has a `atomic.Book` for copyNeeded, seems only used for fast path | ||
|
||
TODO: k8s | ||
|
||
- [ ] https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/util/errors/errors.go | ||
- [ ] https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/util/validation/field/errors.go | ||
|
||
|
||
- implement Formatter interface `Format(f State, c rune)` https://golang.org/pkg/fmt/#Formatter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# hashicorp/errwrap | ||
|
||
- repo: https://github.com/hashicorp/errwrap | ||
- doc: https://godoc.org/github.com/hashicorp/errwrap | ||
- last update: 2014/10/07 | ||
|
||
Usage | ||
|
||
- wrap | ||
- check contains | ||
- get error(s) based on string/type | ||
- walk | ||
|
||
````go | ||
func Contains(err error, msg string) bool | ||
func ContainsType(err error, v interface{}) bool | ||
func GetAll(err error, msg string) []error | ||
func GetAllType(err error, v interface{}) []error | ||
func Walk(err error, cb WalkFunc) | ||
func Wrap(outer, inner error) error | ||
func Wrapf(format string, err error) error | ||
type WalkFunc func(error) | ||
type Wrapper interface { | ||
WrappedErrors() []error | ||
} | ||
```` | ||
|
||
- I was thinking it is using `strings.Contains` but it is actually comparing message directly ... | ||
|
||
````go | ||
// GetAll gets all the errors that might be wrapped in err with the | ||
// given message. The order of the errors is such that the outermost | ||
// matching error (the most recent wrap) is index zero, and so on. | ||
func GetAll(err error, msg string) []error { | ||
var result []error | ||
|
||
Walk(err, func(err error) { | ||
if err.Error() == msg { | ||
result = append(result, err) | ||
} | ||
}) | ||
|
||
return result | ||
} | ||
```` |
Oops, something went wrong.