Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Add Wrapf(cause error, format string, args ...interface{}) error #6

Closed
tilinna opened this issue Apr 24, 2016 · 2 comments
Closed

Add Wrapf(cause error, format string, args ...interface{}) error #6

tilinna opened this issue Apr 24, 2016 · 2 comments

Comments

@tilinna
Copy link

tilinna commented Apr 24, 2016

Instead of this

func Wrap(cause error, message string) error

Have these two

func Annot(cause error, a ...interface{}) error
func Annotf(cause error, format string, a ...interface{}) error

In my opinion, Wrap() doesn't convey the purpose of the function as well as Annot() does. Finally, supporting variadics keeps things consistent with everything else.

@davecheney
Copy link
Member

Hello,

Thank you for your request. I don't plan to rename Wrap at this time as I've just told the world about the old name, and it would be very hard to reach all those people a now. Also, Wrap is shorter that Annot, which itself feels like a compromise spelling of Annotate.

I don't want to make Wrap variadic, as this would make it easy for people to write

cause := fn()
return errors.Wrap(fmt.Errorf("something bad happened in fn", err)

However Wrapf(cause error, format string, args ...interface{}) error sounds fine. Would you like to send a PR ?

@davecheney davecheney changed the title Suggestion: rename Wrap() to Annot() and support variadics Add Wrapf(cause error, format string, args ...interface{}) error Apr 24, 2016
@seh
Copy link
Contributor

seh commented Apr 24, 2016

See #7.

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

No branches or pull requests

3 participants