(t *testing.T)
| 29 | ) |
| 30 | |
| 31 | func 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 | |
| 80 | func makeErr() error { return makeErr2() } |
| 81 | func makeErr2() error { return withstack.WithStack(errors.New("")) } |
nothing calls this directly
no test coverage detected
searching dependent graphs…