Chore: Use x/xerrors instead of pkg/errors (#16668)

* Use xerrors instead of pkg/errors

* Add Wrap util func

* Move Wrap to errutil package
This commit is contained in:
Andrej Ocenas
2019-04-23 11:50:31 +02:00
committed by GitHub
parent 54c1bf0cc9
commit c429934a66
20 changed files with 718 additions and 6 deletions

View File

@ -0,0 +1,11 @@
package errutil
import "golang.org/x/xerrors"
// Wrap is a simple wrapper around Errorf that is doing error wrapping. You can read how that works in
// https://godoc.org/golang.org/x/xerrors#Errorf but its API is very implicit which is a reason for this wrapper.
// There is also a discussion (https://github.com/golang/go/issues/29934) where many comments make arguments for such
// wrapper so hopefully it will be added in the standard lib later.
func Wrap(message string, err error) error {
return xerrors.Errorf("%v: %w", message, err)
}