diff --git a/errbase/format_error.go b/errbase/format_error.go index 8c4fd25..18681eb 100644 --- a/errbase/format_error.go +++ b/errbase/format_error.go @@ -102,7 +102,7 @@ func formatErrorInternal(err error, s fmt.State, verb rune, redactableOutput boo // to enable stack trace de-duplication. This requires a // post-order traversal. Since we have a linked list, the best we // can do is a recursion. - p.formatRecursive(err, true /* isOutermost */, true /* withDetail */) + p.formatRecursive(err, true, true, false, 0) // We now have all the data, we can render the result. p.formatEntries(err) @@ -146,7 +146,7 @@ func formatErrorInternal(err error, s fmt.State, verb rune, redactableOutput boo // by calling FormatError(), in which case we'd get an infinite // recursion. So we have no choice but to peel the data // and then assemble the pieces ourselves. - p.formatRecursive(err, true /* isOutermost */, false /* withDetail */) + p.formatRecursive(err, true, false, false, 0) p.formatSingleLineOutput() p.finishDisplay(verb) @@ -195,7 +195,12 @@ func (s *state) formatEntries(err error) { // Wraps: (N)
// for i, j := len(s.entries)-2, 2; i >= 0; i, j = i-1, j+1 { - fmt.Fprintf(&s.finalBuf, "\nWraps: (%d)", j) + s.finalBuf.WriteByte('\n') + for m := 0; m < s.entries[i].depth-1; m += 1 { + s.finalBuf.WriteByte('|') + s.finalBuf.WriteByte(' ') + } + fmt.Fprintf(&s.finalBuf, "Wraps: (%d)", j) entry := s.entries[i] s.printEntry(entry) } @@ -330,13 +335,28 @@ func (s *state) formatSingleLineOutput() { // s.finalBuf is untouched. The conversion of s.entries // to s.finalBuf is done by formatSingleLineOutput() and/or // formatEntries(). -func (s *state) formatRecursive(err error, isOutermost, withDetail bool) { +func (s *state) formatRecursive(err error, isOutermost, withDetail, withDepth bool, depth int) int { cause := UnwrapOnce(err) + numChildren := 0 if cause != nil { - // Recurse first. - s.formatRecursive(cause, false /*isOutermost*/, withDetail) + // Recurse first, which populates entries list starting from innermost + // entry. If we've previously seen a multi-cause wrapper, `withDepth` + // will be true, and we'll record the depth below ensuring that extra + // indentation is applied to this inner cause during printing. + // Otherwise, we maintain "straight" vertical formatting by keeping the + // parent callers `withDepth` value of `false` by default. + numChildren += s.formatRecursive(cause, false, withDetail, withDepth, depth+1) } + causes := UnwrapMulti(err) + for _, c := range causes { + // Override `withDepth` to true for all child entries ensuring they have + // indentation applied during formatting to distinguish them from + // parents. + numChildren += s.formatRecursive(c, false, withDetail, true, depth+1) + } + // inserted := len(s.entries) - 1 - startChildren + // Reinitialize the state for this stage of wrapping. s.wantDetail = withDetail s.needSpace = false @@ -355,11 +375,11 @@ func (s *state) formatRecursive(err error, isOutermost, withDetail bool) { bufIsRedactable = true desiredShortening := v.SafeFormatError((*safePrinter)(s)) if desiredShortening == nil { - // The error wants to elide the short messages from inner - // causes. Do it. - for i := range s.entries { - s.entries[i].elideShort = true - } + // The error wants to elide the short messages from inner causes. + // Read backwards through list of entries up to the number of new + // entries created "under" this one amount and mark `elideShort` + // true. + s.elideShortChildren(numChildren) } case Formatter: @@ -367,9 +387,7 @@ func (s *state) formatRecursive(err error, isOutermost, withDetail bool) { if desiredShortening == nil { // The error wants to elide the short messages from inner // causes. Do it. - for i := range s.entries { - s.entries[i].elideShort = true - } + s.elideShortChildren(numChildren) } case fmt.Formatter: @@ -394,9 +412,7 @@ func (s *state) formatRecursive(err error, isOutermost, withDetail bool) { if elideChildren { // The error wants to elide the short messages from inner // causes. Do it. - for i := range s.entries { - s.entries[i].elideShort = true - } + s.elideShortChildren(numChildren) } } @@ -419,9 +435,7 @@ func (s *state) formatRecursive(err error, isOutermost, withDetail bool) { if desiredShortening == nil { // The error wants to elide the short messages from inner // causes. Do it. - for i := range s.entries { - s.entries[i].elideShort = true - } + s.elideShortChildren(numChildren) } break } @@ -431,18 +445,20 @@ func (s *state) formatRecursive(err error, isOutermost, withDetail bool) { // fmt.Formatter, but it is a wrapper, still attempt best effort: // print what we can at this level. elideChildren := s.formatSimple(err, cause) + // always elideChildren when dealing with multi-cause errors. + if len(causes) > 0 { + elideChildren = true + } if elideChildren { // The error wants to elide the short messages from inner // causes. Do it. - for i := range s.entries { - s.entries[i].elideShort = true - } + s.elideShortChildren(numChildren) } } } // Collect the result. - entry := s.collectEntry(err, bufIsRedactable) + entry := s.collectEntry(err, bufIsRedactable, withDepth, depth) // If there's an embedded stack trace, also collect it. // This will get either a stack from pkg/errors, or ours. @@ -456,9 +472,21 @@ func (s *state) formatRecursive(err error, isOutermost, withDetail bool) { // Remember the entry for later rendering. s.entries = append(s.entries, entry) s.buf = bytes.Buffer{} + + return numChildren + 1 } -func (s *state) collectEntry(err error, bufIsRedactable bool) formatEntry { +func (s *state) elideShortChildren(newEntries int) { + // TODO(davidh): test case that ensures this works correctly + //for i := range s.entries { + // s.entries[i].elideShort = true + //} + for i := 0; i < newEntries; i++ { + s.entries[len(s.entries)-1-i].elideShort = true + } +} + +func (s *state) collectEntry(err error, bufIsRedactable bool, withDepth bool, depth int) formatEntry { entry := formatEntry{err: err} if s.wantDetail { // The buffer has been populated as a result of formatting with @@ -495,6 +523,10 @@ func (s *state) collectEntry(err error, bufIsRedactable bool) formatEntry { } } + if withDepth { + entry.depth = depth + } + return entry } @@ -708,6 +740,11 @@ type formatEntry struct { // truncated to avoid duplication of entries. This is used to // display a truncation indicator during verbose rendering. elidedStackTrace bool + + // depth, if positive, represents a nesting depth of this + // error as a causer of others. This is used with verbose + // printing to illustrate the nesting depth. + depth int } // String is used for debugging only. diff --git a/errbase/format_error_internal_test.go b/errbase/format_error_internal_test.go index 0e4f93e..72f7940 100644 --- a/errbase/format_error_internal_test.go +++ b/errbase/format_error_internal_test.go @@ -15,11 +15,88 @@ package errbase import ( + goErr "errors" + "fmt" "testing" "github.com/cockroachdb/redact" ) +type wrapMini struct { + msg string + cause error +} + +func (e *wrapMini) Error() string { + return e.msg +} + +func (e *wrapMini) Unwrap() error { + return e.cause +} + +func TestFormatErrorInternal(t *testing.T) { + tests := []struct { + name string + err error + fmtStr string + expected string + }{ + { + name: "single wrapper", + err: fmt.Errorf("%w", fmt.Errorf("a%w", goErr.New("b"))), + fmtStr: "%s", + expected: "ab", + }, + { + name: "simple multi-wrapper", + err: goErr.Join(goErr.New("a"), goErr.New("b")), + fmtStr: "%s", + expected: "a\nb", + }, + { + name: "simple multi-wrapper with single-cause chains inside", + err: goErr.Join(fmt.Errorf("a%w", goErr.New("b")), fmt.Errorf("c%w", goErr.New("d"))), + fmtStr: "%s", + expected: "ab\ncd", + }, + { + name: "simple multi-wrapper with single-cause chains inside (verbose)", + err: goErr.Join(fmt.Errorf("a%w", goErr.New("b")), fmt.Errorf("c%w", goErr.New("d"))), + fmtStr: "%+v", + expected: `ab +(1) ab + | cd +Wraps: (2) cd +| Wraps: (3) d +Wraps: (4) ab +| Wraps: (5) b +Error types: (1) *errors.joinError (2) *fmt.wrapError (3) *errors.errorString (4) *fmt.wrapError (5) *errors.errorString`, + }, + { + name: "test wrapMini", + err: &wrapMini{"whoa: d", goErr.New("d")}, + fmtStr: "%s", + expected: "whoa: d", + }, + { + name: "multi-wrapper where not all children should be elided during printing", + err: fmt.Errorf(""), + fmtStr: "%s", + expected: "whoa: d\nwhoa: d zz", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + fe := Formattable(tt.err) + s := fmt.Sprintf(tt.fmtStr, fe) + if s != tt.expected { + t.Errorf("\nexpected: \n%s\nbut got:\n%s\n", tt.expected, s) + } + }) + } +} + func TestPrintEntry(t *testing.T) { b := func(s string) []byte { return []byte(s) } diff --git a/fmttests/testdata/format/wrap-fmt b/fmttests/testdata/format/wrap-fmt index 91f1008..1911862 100644 --- a/fmttests/testdata/format/wrap-fmt +++ b/fmttests/testdata/format/wrap-fmt @@ -1658,7 +1658,37 @@ outerthree (1) outerthree | outerfour - innerone | innertwo sibling error in wrapper -Error types: (1) *fmt.wrapErrors +Wraps: (2) sibling error in wrapper + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) innerone + | innertwo + | -- this is innerone + | innertwo's + | multi-line leaf payload +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *fmttests.errFmt ===== ===== redactable formats ===== @@ -1676,7 +1706,37 @@ Error types: (1) *fmt.wrapErrors (1) ‹outerthree› ‹ | outerfour - innerone› ‹ | innertwo sibling error in wrapper› -Error types: (1) *fmt.wrapErrors +Wraps: (2) ‹sibling error in wrapper› +‹ | github.com/cockroachdb/errors/fmttests.glob..func23› +‹ | :› +‹ | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirective.func1› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirective› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirectiveOrSubTest› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runTestInternal› +‹ | :› +‹ | github.com/cockroachdb/datadriven.RunTest› +‹ | :› +‹ | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2› +‹ | :› +‹ | github.com/cockroachdb/datadriven.Walk› +‹ | :› +‹ | github.com/cockroachdb/datadriven.Walk.func1› +‹ | :› +‹ | testing.tRunner› +‹ | :› +‹ | runtime.goexit› +‹ | :› +Wraps: (3) ‹innerone› +‹ | innertwo› +‹ | -- this is innerone› +‹ | innertwo's› +‹ | multi-line leaf payload› +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *fmttests.errFmt ===== ===== Sentry reporting ===== @@ -1685,7 +1745,37 @@ Error types: (1) *fmt.wrapErrors (1) × × × -Error types: (1) *fmt.wrapErrors +Wraps: (2) × +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +Wraps: (3) × +× +× +× +× +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *fmttests.errFmt -- report composition: *fmt.wrapErrors == Extra "error types" diff --git a/fmttests/testdata/format/wrap-fmt-via-network b/fmttests/testdata/format/wrap-fmt-via-network index 44573eb..29b2d6a 100644 --- a/fmttests/testdata/format/wrap-fmt-via-network +++ b/fmttests/testdata/format/wrap-fmt-via-network @@ -2229,7 +2229,42 @@ outerthree | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) sibling error in wrapper + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) innerone + | innertwo + | + | (opaque error leaf) + | type name: github.com/cockroachdb/errors/fmttests/*fmttests.errFmt +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errbase.opaqueLeaf == %#v via Formattable() = %#v, good == %v via Formattable() = Error(), good == %s via Formattable() = %v via Formattable(), good @@ -2255,7 +2290,42 @@ Error types: (1) *errbase.opaqueLeaf | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) ‹sibling error in wrapper› + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) ‹innerone› + | ‹innertwo› + | + | (opaque error leaf) + | type name: github.com/cockroachdb/errors/fmttests/*fmttests.errFmt +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errbase.opaqueLeaf ===== ===== Sentry reporting ===== @@ -2267,7 +2337,42 @@ Error types: (1) *errbase.opaqueLeaf | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) × + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) × + | × + | + | (opaque error leaf) + | type name: github.com/cockroachdb/errors/fmttests/*fmttests.errFmt +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errbase.opaqueLeaf -- report composition: *fmt.wrapErrors == Extra "error types" diff --git a/fmttests/testdata/format/wrap-goerr b/fmttests/testdata/format/wrap-goerr index e3594ef..fd97e94 100644 --- a/fmttests/testdata/format/wrap-goerr +++ b/fmttests/testdata/format/wrap-goerr @@ -1513,7 +1513,34 @@ outerthree (1) outerthree | outerfour - innerone | innertwo sibling error in wrapper -Error types: (1) *fmt.wrapErrors +Wraps: (2) sibling error in wrapper + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) innerone + | innertwo +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *errors.errorString ===== ===== redactable formats ===== @@ -1531,7 +1558,34 @@ Error types: (1) *fmt.wrapErrors (1) ‹outerthree› ‹ | outerfour - innerone› ‹ | innertwo sibling error in wrapper› -Error types: (1) *fmt.wrapErrors +Wraps: (2) ‹sibling error in wrapper› +‹ | github.com/cockroachdb/errors/fmttests.glob..func23› +‹ | :› +‹ | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirective.func1› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirective› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirectiveOrSubTest› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runTestInternal› +‹ | :› +‹ | github.com/cockroachdb/datadriven.RunTest› +‹ | :› +‹ | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2› +‹ | :› +‹ | github.com/cockroachdb/datadriven.Walk› +‹ | :› +‹ | github.com/cockroachdb/datadriven.Walk.func1› +‹ | :› +‹ | testing.tRunner› +‹ | :› +‹ | runtime.goexit› +‹ | :› +Wraps: (3) ‹innerone› +‹ | innertwo› +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *errors.errorString ===== ===== Sentry reporting ===== @@ -1540,7 +1594,34 @@ Error types: (1) *fmt.wrapErrors (1) × × × -Error types: (1) *fmt.wrapErrors +Wraps: (2) × +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +Wraps: (3) × +× +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *errors.errorString -- report composition: *fmt.wrapErrors == Extra "error types" diff --git a/fmttests/testdata/format/wrap-goerr-via-network b/fmttests/testdata/format/wrap-goerr-via-network index 31a68aa..2a7846d 100644 --- a/fmttests/testdata/format/wrap-goerr-via-network +++ b/fmttests/testdata/format/wrap-goerr-via-network @@ -1774,7 +1774,39 @@ outerthree | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) sibling error in wrapper + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) innerone + | innertwo +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errors.errorString == %#v via Formattable() = %#v, good == %v via Formattable() = Error(), good == %s via Formattable() = %v via Formattable(), good @@ -1800,7 +1832,39 @@ Error types: (1) *errbase.opaqueLeaf | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) ‹sibling error in wrapper› + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) ‹innerone› +‹ | innertwo› +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errors.errorString ===== ===== Sentry reporting ===== @@ -1812,7 +1876,39 @@ Error types: (1) *errbase.opaqueLeaf | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) × + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) × +× +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errors.errorString -- report composition: *fmt.wrapErrors == Extra "error types" diff --git a/fmttests/testdata/format/wrap-newf b/fmttests/testdata/format/wrap-newf index 6567b1c..0ee6466 100644 --- a/fmttests/testdata/format/wrap-newf +++ b/fmttests/testdata/format/wrap-newf @@ -3135,7 +3135,60 @@ outerthree (1) outerthree | outerfour - new-style innerone | innertwo sibling error in wrapper -Error types: (1) *fmt.wrapErrors +Wraps: (2) sibling error in wrapper + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) attached stack trace + -- stack trace: + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +| Wraps: (4) new-style innerone + | innertwo +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *withstack.withStack (4) *errutil.leafError ===== ===== redactable formats ===== @@ -3153,7 +3206,60 @@ Error types: (1) *fmt.wrapErrors (1) ‹outerthree› ‹ | outerfour - new-style innerone› ‹ | innertwo sibling error in wrapper› -Error types: (1) *fmt.wrapErrors +Wraps: (2) ‹sibling error in wrapper› +‹ | github.com/cockroachdb/errors/fmttests.glob..func23› +‹ | :› +‹ | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirective.func1› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirective› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirectiveOrSubTest› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runTestInternal› +‹ | :› +‹ | github.com/cockroachdb/datadriven.RunTest› +‹ | :› +‹ | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2› +‹ | :› +‹ | github.com/cockroachdb/datadriven.Walk› +‹ | :› +‹ | github.com/cockroachdb/datadriven.Walk.func1› +‹ | :› +‹ | testing.tRunner› +‹ | :› +‹ | runtime.goexit› +‹ | :› +Wraps: (3) attached stack trace + -- stack trace: + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +| Wraps: (4) new-style ‹innerone› + | ‹innertwo› +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *withstack.withStack (4) *errutil.leafError ===== ===== Sentry reporting ===== @@ -3162,7 +3268,60 @@ Error types: (1) *fmt.wrapErrors (1) × × × -Error types: (1) *fmt.wrapErrors +Wraps: (2) × +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +Wraps: (3) attached stack trace + -- stack trace: + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +| Wraps: (4) new-style × + | × +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *withstack.withStack (4) *errutil.leafError -- report composition: *fmt.wrapErrors == Extra "error types" diff --git a/fmttests/testdata/format/wrap-newf-via-network b/fmttests/testdata/format/wrap-newf-via-network index a3001ef..639bb96 100644 --- a/fmttests/testdata/format/wrap-newf-via-network +++ b/fmttests/testdata/format/wrap-newf-via-network @@ -3699,7 +3699,68 @@ outerthree | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) sibling error in wrapper + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) + | (opaque error wrapper) + | type name: github.com/cockroachdb/errors/withstack/*withstack.withStack + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +| Wraps: (4) new-style innerone + | innertwo +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errbase.opaqueWrapper (4) *errutil.leafError == %#v via Formattable() = %#v, good == %v via Formattable() = Error(), good == %s via Formattable() = %v via Formattable(), good @@ -3725,7 +3786,68 @@ Error types: (1) *errbase.opaqueLeaf | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) ‹sibling error in wrapper› + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) + | (opaque error wrapper) + | type name: github.com/cockroachdb/errors/withstack/*withstack.withStack + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +| Wraps: (4) new-style ‹innerone› + | ‹innertwo› +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errbase.opaqueWrapper (4) *errutil.leafError ===== ===== Sentry reporting ===== @@ -3737,7 +3859,68 @@ Error types: (1) *errbase.opaqueLeaf | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) × + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) + | (opaque error wrapper) + | type name: github.com/cockroachdb/errors/withstack/*withstack.withStack + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +| Wraps: (4) new-style × + | × +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errbase.opaqueWrapper (4) *errutil.leafError -- report composition: *fmt.wrapErrors == Extra "error types" diff --git a/fmttests/testdata/format/wrap-nofmt b/fmttests/testdata/format/wrap-nofmt index 666d4e9..c643809 100644 --- a/fmttests/testdata/format/wrap-nofmt +++ b/fmttests/testdata/format/wrap-nofmt @@ -1513,7 +1513,34 @@ outerthree (1) outerthree | outerfour - innerone | innertwo sibling error in wrapper -Error types: (1) *fmt.wrapErrors +Wraps: (2) sibling error in wrapper + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) innerone + | innertwo +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *fmttests.errNoFmt ===== ===== redactable formats ===== @@ -1531,7 +1558,34 @@ Error types: (1) *fmt.wrapErrors (1) ‹outerthree› ‹ | outerfour - innerone› ‹ | innertwo sibling error in wrapper› -Error types: (1) *fmt.wrapErrors +Wraps: (2) ‹sibling error in wrapper› +‹ | github.com/cockroachdb/errors/fmttests.glob..func23› +‹ | :› +‹ | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirective.func1› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirective› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirectiveOrSubTest› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runTestInternal› +‹ | :› +‹ | github.com/cockroachdb/datadriven.RunTest› +‹ | :› +‹ | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2› +‹ | :› +‹ | github.com/cockroachdb/datadriven.Walk› +‹ | :› +‹ | github.com/cockroachdb/datadriven.Walk.func1› +‹ | :› +‹ | testing.tRunner› +‹ | :› +‹ | runtime.goexit› +‹ | :› +Wraps: (3) ‹innerone› +‹ | innertwo› +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *fmttests.errNoFmt ===== ===== Sentry reporting ===== @@ -1540,7 +1594,34 @@ Error types: (1) *fmt.wrapErrors (1) × × × -Error types: (1) *fmt.wrapErrors +Wraps: (2) × +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +Wraps: (3) × +× +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *fmttests.errNoFmt -- report composition: *fmt.wrapErrors == Extra "error types" diff --git a/fmttests/testdata/format/wrap-nofmt-via-network b/fmttests/testdata/format/wrap-nofmt-via-network index ceb99d1..5216746 100644 --- a/fmttests/testdata/format/wrap-nofmt-via-network +++ b/fmttests/testdata/format/wrap-nofmt-via-network @@ -2229,7 +2229,42 @@ outerthree | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) sibling error in wrapper + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) innerone + | innertwo + | + | (opaque error leaf) + | type name: github.com/cockroachdb/errors/fmttests/*fmttests.errNoFmt +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errbase.opaqueLeaf == %#v via Formattable() = %#v, good == %v via Formattable() = Error(), good == %s via Formattable() = %v via Formattable(), good @@ -2255,7 +2290,42 @@ Error types: (1) *errbase.opaqueLeaf | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) ‹sibling error in wrapper› + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) ‹innerone› + | ‹innertwo› + | + | (opaque error leaf) + | type name: github.com/cockroachdb/errors/fmttests/*fmttests.errNoFmt +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errbase.opaqueLeaf ===== ===== Sentry reporting ===== @@ -2267,7 +2337,42 @@ Error types: (1) *errbase.opaqueLeaf | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) × + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) × + | × + | + | (opaque error leaf) + | type name: github.com/cockroachdb/errors/fmttests/*fmttests.errNoFmt +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errbase.opaqueLeaf -- report composition: *fmt.wrapErrors == Extra "error types" diff --git a/fmttests/testdata/format/wrap-pkgerr b/fmttests/testdata/format/wrap-pkgerr index 3bfc433..3a351ff 100644 --- a/fmttests/testdata/format/wrap-pkgerr +++ b/fmttests/testdata/format/wrap-pkgerr @@ -3022,7 +3022,58 @@ outerthree (1) outerthree | outerfour - innerone | innertwo sibling error in wrapper -Error types: (1) *fmt.wrapErrors +Wraps: (2) sibling error in wrapper + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) innerone + | innertwo + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *errors.fundamental ===== ===== redactable formats ===== @@ -3040,7 +3091,58 @@ Error types: (1) *fmt.wrapErrors (1) ‹outerthree› ‹ | outerfour - innerone› ‹ | innertwo sibling error in wrapper› -Error types: (1) *fmt.wrapErrors +Wraps: (2) ‹sibling error in wrapper› +‹ | github.com/cockroachdb/errors/fmttests.glob..func23› +‹ | :› +‹ | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirective.func1› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirective› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirectiveOrSubTest› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runTestInternal› +‹ | :› +‹ | github.com/cockroachdb/datadriven.RunTest› +‹ | :› +‹ | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2› +‹ | :› +‹ | github.com/cockroachdb/datadriven.Walk› +‹ | :› +‹ | github.com/cockroachdb/datadriven.Walk.func1› +‹ | :› +‹ | testing.tRunner› +‹ | :› +‹ | runtime.goexit› +‹ | :› +Wraps: (3) ‹innerone› +‹ | innertwo› +‹ | github.com/cockroachdb/errors/fmttests.glob..func9› +‹ | :› +‹ | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirective.func1› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirective› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runDirectiveOrSubTest› +‹ | :› +‹ | github.com/cockroachdb/datadriven.runTestInternal› +‹ | :› +‹ | github.com/cockroachdb/datadriven.RunTest› +‹ | :› +‹ | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2› +‹ | :› +‹ | github.com/cockroachdb/datadriven.Walk› +‹ | :› +‹ | github.com/cockroachdb/datadriven.Walk.func1› +‹ | :› +‹ | testing.tRunner› +‹ | :› +‹ | runtime.goexit› +‹ | :› +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *errors.fundamental ===== ===== Sentry reporting ===== @@ -3049,7 +3151,58 @@ Error types: (1) *fmt.wrapErrors (1) × × × -Error types: (1) *fmt.wrapErrors +Wraps: (2) × +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +Wraps: (3) × +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +× +Error types: (1) *fmt.wrapErrors (2) *errors.fundamental (3) *errors.fundamental -- report composition: *fmt.wrapErrors == Extra "error types" diff --git a/fmttests/testdata/format/wrap-pkgerr-via-network b/fmttests/testdata/format/wrap-pkgerr-via-network index 9071760..bd55ccd 100644 --- a/fmttests/testdata/format/wrap-pkgerr-via-network +++ b/fmttests/testdata/format/wrap-pkgerr-via-network @@ -3675,7 +3675,68 @@ outerthree | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) sibling error in wrapper + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) innerone + | innertwo + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errbase.opaqueLeaf == %#v via Formattable() = %#v, good == %v via Formattable() = Error(), good == %s via Formattable() = %v via Formattable(), good @@ -3701,7 +3762,68 @@ Error types: (1) *errbase.opaqueLeaf | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) ‹sibling error in wrapper› + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) ‹innerone› + | ‹innertwo› + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errbase.opaqueLeaf ===== ===== Sentry reporting ===== @@ -3713,7 +3835,68 @@ Error types: (1) *errbase.opaqueLeaf | | (opaque error leaf) | type name: fmt/*fmt.wrapErrors -Error types: (1) *errbase.opaqueLeaf +Wraps: (2) × + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Wraps: (3) × + | × + | + | (opaque error leaf) + | type name: github.com/pkg/errors/*errors.fundamental + | reportable 0: + | + | github.com/cockroachdb/errors/fmttests.glob...funcNN... + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2.1 + | : + | github.com/cockroachdb/datadriven.runDirective.func1 + | : + | github.com/cockroachdb/datadriven.runDirective + | : + | github.com/cockroachdb/datadriven.runDirectiveOrSubTest + | : + | github.com/cockroachdb/datadriven.runTestInternal + | : + | github.com/cockroachdb/datadriven.RunTest + | : + | github.com/cockroachdb/errors/fmttests.TestDatadriven.func2 + | : + | github.com/cockroachdb/datadriven.Walk + | : + | github.com/cockroachdb/datadriven.Walk.func1 + | : + | testing.tRunner + | : + | runtime.goexit + | : +Error types: (1) *errbase.opaqueLeaf (2) *errbase.opaqueLeaf (3) *errbase.opaqueLeaf -- report composition: *fmt.wrapErrors == Extra "error types" diff --git a/report/report.go b/report/report.go index 0211722..e326850 100644 --- a/report/report.go +++ b/report/report.go @@ -16,6 +16,7 @@ package report import ( "fmt" + "os" "strings" "github.com/cockroachdb/errors/domains" @@ -34,7 +35,7 @@ import ( // // A Sentry report is displayed visually in the Sentry UI as follows: // -//////////////// +// ////////////// // Title: (1) some prefix in bold (2) one line for a stack trace // (3) a single-line subtitle // @@ -44,21 +45,24 @@ import ( // (5) a "message" // // (6) zero or more "exceptions", each composed of: -// (7) a bold title -// (8) some freeform text -// (9) a stack trace +// +// (7) a bold title +// (8) some freeform text +// (9) a stack trace // // (10) metadata fields: environment, arch, etc // // (11) "Additional data" fields // // (12) SDK version -///////////////// +// /////////////// // // These visual items map to the Sentry Event object as follows: // // (1) the Type field of the 1st Exception object, if any -// otherwise the Message field +// +// otherwise the Message field +// // (2) the topmost entry from the Stacktrace field of the 1st Exception object, if any // (3) the Value field of the 1st Exception object, if any, unwrapped as a single line // (4) the Tags field @@ -78,7 +82,9 @@ import ( // (3)/(8): first line of verbose error printout // (4): not populated in this function, caller is to manage this // (5): detailed structure of the entire error object, with references to -// additional "exception" objects +// +// additional "exception" objects +// // (9): generated from innermost stack trace // (6): every exception object after the 1st reports additional stack trace contexts // (11): the detailed error types and their error mark. @@ -92,7 +98,6 @@ import ( // is included in the Sentry report. This does not affect error types // provided by the library, but could impact error types defined by // 3rd parties. This limitation may be lifted in a later version. -// func BuildSentryReport(err error) (event *sentry.Event, extraDetails map[string]interface{}) { if err == nil { // No error: do nothing. @@ -320,6 +325,8 @@ func BuildSentryReport(err error) (event *sentry.Event, extraDetails map[string] // (func) // [: ] + z := os.Stdout + var newValueBuf strings.Builder // Note that "first exception" is the last item in the slice, // because... Sentry is annoying.