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

replace hashicorp/errwrap with go1.13 native error wrapping #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thaJeztah
Copy link

The errwrap.Wrapf() function was deprecated in favor of native go 1.13 error
wrapping in github.com/hashicorp/errwrap v1.1.0 (hashicorp/errwrap#9).

This updates the Prefix() function to use native error wrapping, which removes the dependency on github.com/hashicorp/errwrap.

The `errwrap.Wrapf()` function was deprecated in favor of native go 1.13 error
wrapping in github.com/hashicorp/errwrap v1.1.0.

This updates the `Prefix()` function to use native error wrapping, which removes
the dependency on github.com/hashicorp/errwrap.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@hashicorp-cla
Copy link

hashicorp-cla commented Mar 1, 2022

CLA assistant check
All committers have signed the CLA.

@thaJeztah
Copy link
Author

thaJeztah commented Mar 1, 2022

@dnephin @mitchellh PTAL 🤗 (noticed this was deprecated when updating dependencies (moby/moby#43308), so thought I could as well try to get rid of that dependency altogether 😅)

@lovromazgon
Copy link

@mitchellh @mwhooker are there any plans to merge this PR?

@displague
Copy link

displague commented Feb 28, 2024

I found this issue while considering further adoption of this package vs the upstream support in Go 1.20 for wrapper errors.

See

@@ -17,7 +13,7 @@ func Prefix(err error, prefix string) error {
return nil
}

format := fmt.Sprintf("%s {{err}}", prefix)
format := prefix + " %w"
Copy link

Choose a reason for hiding this comment

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

prefix might contain %. It must not be concatenated with formatting word.

@@ -27,11 +23,11 @@ func Prefix(err error, prefix string) error {

// Wrap each of the errors
for i, e := range err.Errors {
err.Errors[i] = errwrap.Wrapf(format, e)
err.Errors[i] = fmt.Errorf(format, e)
Copy link

Choose a reason for hiding this comment

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

Suggested change
err.Errors[i] = fmt.Errorf(format, e)
err.Errors[i] = fmt.Errorf("%s %w", prefix, e)

}

return err
default:
return errwrap.Wrapf(format, err)
return fmt.Errorf(format, err)
Copy link

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf(format, err)
return fmt.Errorf("%s %w", prefix, err)

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

5 participants