MCPcopy Index your code
hub / github.com/go-errors/errors / compareStacks

Function compareStacks

error_test.go:296–306  ·  view source on GitHub ↗

compareStacks will compare a stack created using the errors package (actual) with a reference stack created with the callers function (expected). The first entry is not compared since the actual and expected stacks cannot be created at the exact same program counter position so the first entry will

(actual, expected []uintptr)

Source from the content-addressed store, hash-verified

294// will always differ somewhat. Returns nil if the stacks are equal enough and
295// an error containing a detailed error message otherwise.
296func compareStacks(actual, expected []uintptr) error {
297 if len(actual) != len(expected) {
298 return stackCompareError("Stacks does not have equal length", actual, expected)
299 }
300 for i, pc := range actual {
301 if i != 0 && pc != expected[i] {
302 return stackCompareError(fmt.Sprintf("Stacks does not match entry %d (and maybe others)", i), actual, expected)
303 }
304 }
305 return nil
306}
307
308func stackCompareError(msg string, actual, expected []uintptr) error {
309 return fmt.Errorf("%s\nActual stack trace:\n%s\nExpected stack trace:\n%s", msg, readableStackTrace(actual), readableStackTrace(expected))

Callers 3

TestStackFormatFunction · 0.85
TestSkipWorksFunction · 0.85
TestNewFunction · 0.85

Calls 1

stackCompareErrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…