Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discussion(errors): Use github.com/cockroachdb/errors instead of pkg/errors #27

Closed
gaocegege opened this issue Apr 21, 2022 · 5 comments · Fixed by #44
Closed

discussion(errors): Use github.com/cockroachdb/errors instead of pkg/errors #27

gaocegege opened this issue Apr 21, 2022 · 5 comments · Fixed by #44
Assignees
Labels
good first issue ❤️ Good for newcomers help wanted 🆘 Extra attention is needed priority/3-low 💙

Comments

@gaocegege
Copy link
Member

Description

#14 (comment)

IMO, the crucial use of pkg/error is it implements the method Unwrap, and thus we can use errors.Is to see if two errors are the same.

But pkg/error is in the maintain mode, should we use this one instead?

@gaocegege
Copy link
Member Author

/cc @Thrimbda

Are you interested in fixing it? Or I will work on it soon.

@gaocegege gaocegege removed their assignment Apr 21, 2022
@gaocegege gaocegege added good first issue ❤️ Good for newcomers help wanted 🆘 Extra attention is needed labels Apr 21, 2022
@gaocegege gaocegege changed the title chore(errors): Use github.com/cockroachdb/errors instead of pkg/errors discussion(errors): Use github.com/cockroachdb/errors instead of pkg/errors Apr 22, 2022
@gaocegege
Copy link
Member Author

the crucial use of pkg/error is it implements the method Unwrap

Actually the builtin fmt.Errorf could do the same thing, please see also https://pkg.go.dev/errors#Unwrap.

As for me, the advantage of using github.com/pkg/errors is we could see the call stack, which is not supported by fmt.Errorf("%w").

Personally prefer github.com/pkg/errors since it provides many wrappers and helper functions.

My two cents is that we could provide an internal package with the similar API using fmt.Errorf if we are not interested in the call stack and do not want to risk ourselves using a not maintained Go module.

From @knight42

@gaocegege
Copy link
Member Author

Yeah, I think the main advantage is the stack. We may need it since we have a frontend language starlark, and stack trace is what we need to print the error when there is a language error.

@Thrimbda
Copy link
Member

Are you interested in fixing it? Or I will work on it soon.

You mean to replace pkg/errors with the package I mentioned?

Anyway, I am interested in doing the work.

@gaocegege
Copy link
Member Author

You mean to replace pkg/errors with the package I mentioned?

Yeah. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue ❤️ Good for newcomers help wanted 🆘 Extra attention is needed priority/3-low 💙
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants