You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error.New method provides the same functionality as errors.Wrap function (it is an alias). I think that Wrap function provides a better information of what the implementation is doing and what the result is. errors.Wrap cannot be removed because this is the only way to wrap an error. Error.New method cannot be used for this.
I also find the Newf functionality very handy (it came up after lots of tedious error writing), so I would propose:
Add errors.Wrapf(), which is errors.Wrap and fmt.Sprintf combines (like Newf is).done
Convert all usages of ErrXyz.New("foo") to errors.Wrap(ErrXyz, "foo")
Convert all usages of ErrXyz.Newf("foo %s", ...) to errors.Wrapf(ErrXyz, "foo %s", ...)
Remove Error.New and Error.Newf
Ideally the two conversion steps can be automated with a clever regexp
The text was updated successfully, but these errors were encountered:
Use `errors.Wrap` and `errors.Wrapf` insteand of `New` and `Newf`
methods. This is a removal of a syntatic sugar.
Using `Wrap` function instead of method allows for consistent usage of
error wrapping. Before it could have been confusing when to use `Wrap`
and when `New`.
resolve#382
Use `errors.Wrap` and `errors.Wrapf` insteand of `New` and `Newf`
methods. This is a removal of a syntatic sugar.
Using `Wrap` function instead of method allows for consistent usage of
error wrapping. Before it could have been confusing when to use `Wrap`
and when `New`.
resolve#382
Based on #368
Error.New
method provides the same functionality aserrors.Wrap
function (it is an alias). I think thatWrap
function provides a better information of what the implementation is doing and what the result is.errors.Wrap
cannot be removed because this is the only way to wrap an error.Error.New
method cannot be used for this.I also find the
Newf
functionality very handy (it came up after lots of tedious error writing), so I would propose:Adddoneerrors.Wrapf()
, which iserrors.Wrap
andfmt.Sprintf
combines (likeNewf
is).ErrXyz.New("foo")
toerrors.Wrap(ErrXyz, "foo")
ErrXyz.Newf("foo %s", ...)
toerrors.Wrapf(ErrXyz, "foo %s", ...)
Error.New
andError.Newf
Ideally the two conversion steps can be automated with a clever regexp
The text was updated successfully, but these errors were encountered: