Skip to content

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 <[email protected]>
@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

}

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.

// 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.

5 participants