First of all, thanks for this very useful library.
Here is a small improvement that I would find useful : It adds a method to wrap errors while providing context (as a prefix to the error message).
The use case would be to add meaningful context (in english) to users that may not have access to the source-code (in my case a CLI tool)
Here is an example use case:
func ReadFile() *errors.Error {
return errors.Errorf("File does not exist")
}
func ConquerTheWorld() *errors.Error {
err := ReadFile()
if err != nil {
return errors.WrapPrefix(err, "Unable to read file", 1)
}
}
err := ConquerTheWorld()
err.Error() == "Unable to read file: File does not exist"
The wrapped error has the same properties than with Wrap (keeps the stack trace etc)
Let me know what you think.
Best,
Hello,
First of all, thanks for this very useful library. Here is a small improvement that I would find useful : It adds a method to wrap errors while providing context (as a prefix to the error message). The use case would be to add meaningful context (in english) to users that may not have access to the source-code (in my case a CLI tool)
Here is an example use case:
The wrapped error has the same properties than with
Wrap
(keeps the stack trace etc) Let me know what you think. Best,