hashicorp / errwrap Goto Github PK
View Code? Open in Web Editor NEWErrwrap is a Go (golang) library for wrapping and querying errors.
License: Mozilla Public License 2.0
Errwrap is a Go (golang) library for wrapping and querying errors.
License: Mozilla Public License 2.0
Looking at the doc and trying out the tool I noticed that the Wrapf function is deprecated but the documentation still refers to use it instead of fmt.Errorf. At this point the README is deprecated too, right?
For context, we have similar wrapping code here: https://github.com/cloudfoundry/bosh-agent/blob/master/errors/errors.go#L52
I'm wondering why you guys decided to allow the user to specify where (and if) the error string from the wrapped error gets included in the new error message.
Do you have special use cases where you need to format them differently? It seems like having a standard pattern would be sufficient, like fmt.Sprintf("%s: %s", msg, err.Error())
.
We found that if more complex formatting was required the user could easily traverse the error chain and craft their own custom message format, like we did here: https://github.com/cloudfoundry/bosh-init/blob/master/ui/fmt/error.go
https://github.com/hashicorp/errwrap#basic-usage:
// ...
if errwrap.Contains(err, ErrNotExist) {
// Do something
}
// ...
errwrap.Contains
type signature is func Contains(err error, msg string) bool
. However ErrNotExist
has the same name as os.ErrNotExist
and seems to contain an error
based on naming. This is conflicting usage. Is the type signature wrong, or the usage documentation?
It might be useful to have Wrap
and Wrapf
equivalents that return nil
when given nil
input, allowing the called to avoid preceding these calls with a nil
check. Would you accept a PR for this?
Should this package be deprecated in favor of https://go.dev/doc/go1.20#errors?
Should this package simplify and wrap the native implementation? If so, would anything be left? What benefits remain after such a refactor?
Similar to:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.