Uh oh!
There was an error while loading. Please reload this page.
Fixed #102, a message formatting bug. - #114
Conversation
davecheney
commented
May 5, 2017
Not LGTM sorry. Do we need a field on withMessage? Can't you do type assertion instead? |
Essentially, there are two use cases we want to meet here.
If you use type assertion to accomplish this, you might do the type assertion in the func (w*withStack) Format(s fmt.State, verbrune) {
switchverb {
case'v':
ifs.Flag('+') {
withMessageWrapper, ok:=w.Cause().(*withMessage) // Type Assertionifok { // Run this whenever we have a withMessage next in the chainfmt.Fprintf(s, "%+v\n", withMessageWrapper.Cause())
io.WriteString(s, withMessageWrapper.msg)
w.stack.Format(s, verb)
} else { // Run this for anything else next in the chainfmt.Fprintf(s, "%+v", w.Cause())
w.stack.Format(s, verb)
}
return
}
fallthroughcase's':
io.WriteString(s, w.Error())
case'q':
fmt.Fprintf(s, "%q", w.Error())
}
}This introduces an issue that from that scope there is no way to determine whether the The scenario can easily occur where a pre-existing Maybe that is a viable solution? Is there a scenario where a |
gregwebs
commented
Sep 11, 2018
Does it help to use |
hanzei
commented
Apr 17, 2019
What is the status of this PR? Does the comment above helped the discussion? |
Fixes#102
With these changes, when using a plain
withMessage(), we'll print the additional message in front of the original error message, above the stack trace. This maintains the correct ordering when an error is beingWrap()'d, printing the message + second stack trace after the first message + stack trace.