graphql-go icon indicating copy to clipboard operation
graphql-go copied to clipboard

Thoughts on using github.com/pkg/errors for errors

Open dvic opened this issue 6 years ago • 3 comments

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.

dvic avatar Mar 28 '18 10:03 dvic

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?

tonyghita avatar Mar 30 '18 16:03 tonyghita

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 :)

dvic avatar Apr 04 '18 16:04 dvic

Yes I would consider that an option 👍

tonyghita avatar Apr 04 '18 17:04 tonyghita

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.).

mitar avatar Oct 09 '23 09:10 mitar

I'm closing this issue as it doesn't currently solve some issue with this library.

pavelnikolov avatar Oct 09 '23 11:10 pavelnikolov