Hi!
Yes, I have. My view is that both
github.com/pkg/errors and
gitlab.com/tozd/go/errors aim at being more or less a drop-in
replacement for core errors, but adding stack traces to errors. Since
Go has now Errorf which can wrap existing errors to augment their
messages, the utility functions in
github.com/pkg/errors and
gitlab.com/tozd/go/errors are not really necessary, but they still
make some common cases easy. So my view is that these two packages
could be something which could be used in a wide range of packages to
produce errors, when the package also wants to return a stack trace
with the error.
On the other hand,
github.com/cockroachdb/errors has so many features
that to effecticelly use it one has to coordinate around the codebase
how exactly different features are used to get consistency. So it is
less useful in my opinion for 3rd party packages and more as something
you would use in your own large codebase (which you more or less
control). But it has all possible features you might ever want. Maybe
it could be cool if
github.com/cockroachdb/errors would be built on
top of
gitlab.com/tozd/go/errors, to use when you need all those
additional features.
Additionally, I am personally not too convinced about storing end-user
hints into errors themselves. Maybe that works for some people, but to
me errors are something useful to control program flow and to debug by
developers, while showing hints to end users is generally something
one has to do separately (e.g., because you have to translate that
hint anyway to the user's language). So to me a pattern I prefer, and
gitlab.com/tozd/go/errors enables, is to have a set of base errors
(e.g., io.EOF) which you then augment with the stack trace at the
point where they happen, and then when you are handling errors you use
`errors.Is` to determine which of base errors happened and map that to
a message for the end user, in their language. So in a way,
github.com/cockroachdb/errors has too much stuff for me, so I prefer
something leaner.
Mitar
On Mon, Jan 3, 2022 at 7:27 AM Gaurav Maheshwari
<
gaurav...@gmail.com> wrote:
>
> Did you check
https://github.com/cockroachdb/errors ? How does it differ from cockroachdb/errors?
>> --
>> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to
golang-nuts...@googlegroups.com.
>> To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/CAKLmikOVd%3DaV01QQf8xUE5vOxqarz7dsrit0V3pgT_XsaQuGow%40mail.gmail.com.
>
>
>
> --
> Gaurav Maheshwari