errors.go 545 B

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