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

update pkg/errors to v0.9.1 #114

Merged
merged 1 commit into from
May 16, 2020

Conversation

thaJeztah
Copy link
Contributor

This version plays well with go1.13 and up "wrapped" errors, and makes sure that errors.Unwrap(), errors.Is() and errors.As() are able to get the wrapped error.

This version plays well with go1.13 and up "wrapped" errors,
and makes sure that `errors.Unwrap()`, `errors.Is()` and `errors.As()`
are able to get the wrapped error.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Contributor Author

Once go < 1.13 is no longer supported by this library, GetExitCode could be rewritten to something like;

// GetExitCode returns the ExitStatus of a process from the error returned by
// exec.Run(). If the exit status is not available an error is returned.
func GetExitCode(err error) (int, error) {
	var exitErr exec.ExitError
	if errors.As(err, &exitErr) {
		if procExit, ok := exitErr.Sys().(syscall.WaitStatus); ok {
			return procExit.ExitStatus(), nil
		}
	}
	return 0, errors.Wrap(err, "failed to get exit code")
}

@dnephin
Copy link
Member

dnephin commented May 16, 2020

Thanks!

I think once go1.11 and go1.12 support is dropped I will probably remove the dependency and use %w.

@dnephin dnephin merged commit 04af7e1 into gotestyourself:master May 16, 2020
@thaJeztah thaJeztah deleted the bump_pkg_errors branch May 16, 2020 19:03
@thaJeztah
Copy link
Contributor Author

I think once go1.11 and go1.12 support is dropped I will probably remove the dependency and use %w.

Be careful doing so, because if "downstream" users of this package (not sure if that's something in practice) didn't switch to replace errors.Cause() to errors.Is(), they won't get the underlying error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants