-
Notifications
You must be signed in to change notification settings - Fork 707
Destructure Wrap/Wrapf into component operations #76
Conversation
8ae1d01
to
2bc834e
Compare
@@ -193,6 +205,18 @@ func Wrapf(err error, format string, args ...interface{}) error { | |||
} | |||
} | |||
|
|||
// WithMessage annotates err with a new message. | |||
// If err is nil, WithStack returns nil. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/WithStack/WithMessage/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cep21 please send a PR to this PR
Added PR to this PR to address the comment issue. Anything else I can help with to advance this PR? I can fix merge conflicts with master if you let me know whether you prefer merging master in or rebasing the PR on master and fixing that way. If there are any TODO items that could be tackled I could take a look as well -- would really like to see this functionality soon! |
This reverts commit 1b876e0.
Adds testFormatCompleteCompare as additional testing func. The new function takes a string slice as "want", wherein stacktraces and non-stacktrace messages are discerned by strings.ContainsAny(want[i], "\n"). For example usage, see TestFormatWithStack & TestFormatWithMessage.
1aaa9a1
to
17b7af7
Compare
I know this may be a bit silly, but WithMessagef would be nice addition as well. When converted "too many stack traces" code from Wrap -> WithMessage, converting Wrapf means an internal fmt.Sprintf(). |
This PR is a result of the discussions at GopherCon. The focus of the branch is to decompose Wrap (and Wrapf) into their component operations, namely adding a message,
errors.WithMessage
and adding a stack trace,errors.WithStack
which were previously merged into one operation with Wrap.This is accomplished by adding two top level functions,
errors.WithMessage
anderrors.WithStack
and rewriting Wrap and Wrap to work in terms of these operations although a small deviation is present to make sure the recorded stack trace is correct.The motivation for this change was need to treat each of the following operations as distinct:
TODO: