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
Sometimes as we pass the error down the line we might want to annotate the error with more information and we don't want to check its type later. For these cases, Kind is an overkill, because you need to declare a kind and then use Wrap.
A Wrap top-level function could be nice for this use-case.
iferr!=nil {
returnnil, errors.Wrap(err, "couldn't get value at position %d", position)
}
Instead of:
varerrCantGetValueAtPos=errors.NewKind("couldn't get value at position %d")
iferr!=nil {
returnnil, errCantGetValueAtPos.Wrap(err, position)
}
It enables having ad-hoc error messages just for adding info and reduces the amount of kinds that need to be declared.
Reference:
xerrors.Errorf in the new experimental errors package that is probably going into Go 1.13.
Activity
[-]Wrap errors with no kind[/-][+][Proposal] Wrap errors with no kind[/+]