Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[errors] Replace pkg/errors Fix #54 #59

Merged
merged 11 commits into from
Feb 25, 2018
Merged

[errors] Replace pkg/errors Fix #54 #59

merged 11 commits into from
Feb 25, 2018

Conversation

at15
Copy link
Member

@at15 at15 commented Feb 24, 2018

  • survey
  • interface
    • stack is not that important .... and pkg/errors is using old API
    • multi error is pretty useful
    • we want to have machine readable types, so we can do something in post processing
      • i.e. show a colorful page with stack when developer is using browser ....
  • update errors package usage inside gommon

TODO in next PR

  • support cause
  • support print stack by implementing the fmt.Formatter interface
  • machine readable error types

- #54
- hashicorp/errwrap supports get/check error by message or type and walk
  - which is more handy than just get the root cause
- hashicorp/go-multierror can faltten multierror when append
  - ErrOrNil, because nil pointer is not nil error
  - https://golang.org/doc/faq#nil_error Why is my nil error value not equal to nil?
- uber/multierr
  - [ ] has a atomic value to deal with copy?
  - is trying to integrate with zap
  - suggests return two value when append
at15 added 10 commits February 24, 2018 13:18
- safe version is guarded by a mutex, and make a copy of errors when
`Errors` is called
- unsafe (default) version just `errs = append(errs, err)` and return
the underlying slice directly (no copy) when `Errors` is called
- flatten is supported, when append, check if it's a MultiErr interface
- otherwise the `// Code generated ...` will be treated as package comment
  - this may be intended behavior for protobuf, but not for gommon in
most cases
- [doc] update the doc for most packages, most of them were blank
- [ ] FIXME: runtime.Frames can only be read once
- when use *runtime.Frames, it can only be read once
- the drawback is, we many not always need the full frames
  - actually a lot of time the full stack is never printed ...
- when `Frames()` is not called, *runtime.Frames is not traversed
  - it should increase performance (in theory) ...
- since the methods are same, `Wrap` and `Wrapf`, most files only need
to change the import path
- all the `WithMessage` are replaced with `Wrap` because we check
existing stack before attach stack to error
- add `HasError` to avoid writing `ErrorOrNil != nil`
@at15 at15 merged commit b950eeb into master Feb 25, 2018
@at15 at15 deleted the errors/init branch February 25, 2018 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant