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

pkg/private/serrors: act the constructors deprecations #4595

Merged
merged 16 commits into from
Aug 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve comments.
  • Loading branch information
jiceatscion committed Aug 13, 2024
commit 0d290378935cacbafd62d05e0632bc44e8e515bb
14 changes: 8 additions & 6 deletions pkg/private/serrors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,18 @@ func (e basicError) MarshalLogObject(enc zapcore.ObjectEncoder) error {
//
// This is best used when adding context to an error that already has some. The existing error is
// used as the cause; all its existing context and stack trace are preserved for printing and
// logging. The new context is attached to the new error. It can be used without an underlying
// cause by passing nil as the cause. In that case this behaves like New(), except that the
// underlying type of the returned interface is basicError, rather than a *basicError. To enrich a
// sentinel error, do not use
// logging. The new context is attached to the new error.
//
// Passing nil as the cause is legal but of little use. In that case, prefer [New]. The only
// difference is the underlying type of the returned interface.
//
// To enrich a sentinel error, do not use
//
// Wrap("dummy message", sentinel, ...)
//
// instead use
//
// Join(sentinel, nil, ...)
// [Join](sentinel, nil, ...)
func Wrap(msg string, cause error, errCtx ...interface{}) error {
return basicError{
errorInfo: mkErrorInfo(cause, true, errCtx...),
Expand Down Expand Up @@ -251,7 +253,7 @@ func (e joinedError) MarshalLogObject(enc zapcore.ObjectEncoder) error {
// The returned error supports Is. If cause isn't nil, Is(cause) returns true. Is(error) returns
// true.
//
// This is best used as an alternative to Wrap when deriving an error from a sentinel error. If
// This is best used as an alternative to [Wrap] when deriving an error from a sentinel error. If
// there is an underlying error it may be used as the cause (with the same effect as Wrap(). If
// creating a new error (not due to an underlying error) nil may be passed as the cause. In that
// case the result is a sentinel error enriched with context. For such a purpose this is better than
Expand Down