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

Do not use errgo nor pkg/errors for root errors, matches stdlib #584

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Soulou
Copy link
Member

@Soulou Soulou commented Apr 6, 2023

Expose New to create simple string errors, wrapping pkg/errors.New
Expose NewWithContext/Newf/Errorf, to create errors which are not wrapping others

Related to #582

@Soulou Soulou self-assigned this Apr 6, 2023
@Soulou Soulou requested a review from EtienneM April 6, 2023 22:56
@Soulou Soulou force-pushed the feat/582/match-stdlib branch from 7664a77 to d310f9d Compare April 6, 2023 23:11
Comment on lines +28 to +31
// New wraps errors.New from the pkg/errors library
//
// These errors are usually created outside any function code at the top of
// files, so no context is needed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I would keep a first line of comment explaining what this function do.

Suggested change
// New wraps errors.New from the pkg/errors library
//
// These errors are usually created outside any function code at the top of
// files, so no context is needed.
// New returns an error that formats as the given text.
// New wraps errors.New from the pkg/errors library
//
// These errors are usually created outside any function code at the top of
// files, so no context is needed.

errors/errctx.go Show resolved Hide resolved
}

func Errorf(ctx context.Context, format string, args ...interface{}) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need both Newf and Errorf? correct me if I'm wrong but they seem identical.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right it was to prevent breaking the API more

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hence should we mark one of these two methods as deprecated?

errors/errctx.go Outdated Show resolved Hide resolved
errors/errctx.go Outdated Show resolved Hide resolved
Soulou and others added 2 commits May 3, 2023 11:15
Co-authored-by: Étienne M. <[email protected]>
Co-authored-by: Étienne M. <[email protected]>
@Soulou Soulou requested a review from EtienneM May 3, 2023 09:16
Copy link
Member

@EtienneM EtienneM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one remaining question. Already approving whatever the answer

}

func Errorf(ctx context.Context, format string, args ...interface{}) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hence should we mark one of these two methods as deprecated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants