MCPcopy Index your code
hub / github.com/cockroachdb/errors / TestReportableStackTrace

Function TestReportableStackTrace

withstack/reportable_test.go:31–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29)
30
31func TestReportableStackTrace(t *testing.T) {
32 baseErr := errors.New("hello")
33
34 t.Run("pkgErr", func(t *testing.T) {
35 err := internal.Run(func() error { return pkgErr.WithStack(baseErr) })
36 t.Run("local", func(t *testing.T) {
37 checkStackTrace(t, err, 0)
38 })
39 enc := errbase.EncodeError(context.Background(), err)
40 err = errbase.DecodeError(context.Background(), enc)
41 t.Run("remote", func(t *testing.T) {
42 checkStackTrace(t, err, 0)
43 })
44 })
45
46 t.Run("pkgFundamental", func(t *testing.T) {
47 err := internal.Run(func() error { return pkgErr.New("hello") })
48 t.Run("local", func(t *testing.T) {
49 checkStackTrace(t, err, 0)
50 })
51 enc := errbase.EncodeError(context.Background(), err)
52 err = errbase.DecodeError(context.Background(), enc)
53 t.Run("remote", func(t *testing.T) {
54 checkStackTrace(t, err, 0)
55 })
56 })
57
58 t.Run("withStack", func(t *testing.T) {
59 err := internal.Run(func() error { return withstack.WithStack(baseErr) })
60 t.Run("local", func(t *testing.T) {
61 checkStackTrace(t, err, 0)
62 })
63 enc := errbase.EncodeError(context.Background(), err)
64 err = errbase.DecodeError(context.Background(), enc)
65 t.Run("remote", func(t *testing.T) {
66 checkStackTrace(t, err, 0)
67 })
68 })
69
70 t.Run("withStack depth", func(t *testing.T) {
71 err := internal.Run(makeErr)
72 checkStackTrace(t, err, 1)
73 })
74 t.Run("withStack nontrival depth", func(t *testing.T) {
75 err := internal.Run(makeErr3)
76 checkStackTrace(t, err, 0)
77 })
78}
79
80func makeErr() error { return makeErr2() }
81func makeErr2() error { return withstack.WithStack(errors.New("")) }

Callers

nothing calls this directly

Calls 6

RunFunction · 0.92
EncodeErrorFunction · 0.92
DecodeErrorFunction · 0.92
WithStackFunction · 0.92
checkStackTraceFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…