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

Add wrap verb to formatted error outputs #817

Merged
merged 1 commit into from
Feb 17, 2021

Conversation

mkatychev
Copy link
Contributor

@mkatychev mkatychev commented Feb 17, 2021

  • Replaces %v formatting of errors using fmt.Errorf with %w.
  • In cases where an Unwrap method is not used, %w behaves in the exact same way as %v.

Reference:

In Go 1.13, the fmt.Errorf function supports a new %w verb. When this verb is present, the error returned by fmt.Errorf will have an Unwrap method returning the argument of %w, which must be an error. In all other ways, %w is identical to %v.

This would allow returned errors such as this one to check and handle cases when the underlying error is os.ErrNotExist using os.IsNotExist(err):
https://github.com/mozilla/sops/blob/8e21de8dbc750f050a54d63209f2f1f93477168c/decrypt/decrypt.go#L21-L24

@autrilla autrilla self-requested a review February 17, 2021 21:21
Copy link
Contributor

@autrilla autrilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@autrilla autrilla merged commit 0f2ebcf into getsops:develop Feb 17, 2021
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