3 ms·
Having been writing Go for 4 years now, I can say that Dave Cheney's package is exactly what I've been looking for. The thing that really sells it to me is the
by nickcw 10y ago
Having been writing Go for 4 years now, I can say that Dave Cheney's package is exactly what I've been looking for.
The thing that really sells it to me is the being able to wrap the error when necessary with errors.Wrap and find the underlying cause with errors.Cause. I've yet to experiment with the new formatting `%+v` but I can see that coming in useful too.
There have been earlier attempts at something similar (eg https://github.com/juju/errors https://github.com/juju/errors) but none with the same clarity of thought.
So thanks for a great package Dave and for taking the time to whittle it down into the simplest, most elegant thing.
- themartorana 10y agoWe've been doing this via an in-house errors package for a while. It does other things, like log request ID with the error for tracing and whatnot, and uses a bit of code adopted from panicparse [0] to print pretty, easy-on-the-eyes, quickly-parsable stack traces. Honestly I don't know why stack traces aren't formatted for quick parsing. Many thanks to maruel [1] for the inspiration. [0] https://github.com/maruel/panicparse https://github.com/maruel/panicparse [1] https://github.com/maruel https://github.com/maruel