graphql-go
graphql-go copied to clipboard
Thoughts on using github.com/pkg/errors for errors
I'd like to propose the idea of using github.com/pkg/errors
for errors.
Logging regular errors and panic errors could give us proper stack traces which makes debugging / fixing problems much easier because you can see from where the error has been returned.
I have already applied this on our fork (see https://travis-ci.org/qdentity/graphql-go) and all tests pass.
I'm happy to create a PR if this idea is also useful for this repo.
I think adding a stacktrace is a good idea. I believe the preference for this library is to keep external dependencies minimal.
Maybe there exists a way to get the stacktraces without adding the dependency? What do you think about that?
The github.com/pkg/errors
is very small, we could just copy the bare minimal structs and API that we need to get nice stacktraces and proper error formatting. The license of pkg/errors
is the BSD 2-Clause "Simplified" License. Is this an option? Let me know, I'm willing to put this into a PR :)
Yes I would consider that an option 👍
github.com/pkg/errors
has been archived and is not maintained anymore. You should maybe consider switching to something else instead as you are updating error handling?
Shameless plug: you can switch it to drop-in replacement gitlab.com/tozd/go/errors
. It fixes many issues, is maintained, and supports modern Go's error patterns (sentinel errors, %w formatting, joined errors, etc.).
I'm closing this issue as it doesn't currently solve some issue with this library.