MCPcopy Index your code
hub / github.com/bracesdev/errtrace / Wrap

Function Wrap

wrap.go:12–18  ·  view source on GitHub ↗

Wrap adds information about the program counter of the caller to the error. This is intended to be used at all return points in a function. If err is nil, Wrap returns nil. go:noinline so caller's PC is saved in the stack frame for asm GetCaller.

(err error)

Source from the content-addressed store, hash-verified

10//
11//go:noinline so caller's PC is saved in the stack frame for asm GetCaller.
12func Wrap(err error) error {
13 if err == nil {
14 return nil
15 }
16
17 return wrap(err, pc.GetCaller())
18}
19
20// Wrap2 is used to [Wrap] the last error return when returning 2 values.
21// This is useful when returning multiple returns from a function call directly:

Callers 15

TestWrapNilFunction · 0.92
TestWrappedErrorFunction · 0.92
TestWrappedErrorIsFunction · 0.92
TestWrappedErrorAsFunction · 0.92
TestFormatTraceFunction · 0.92
TestFormatVerbsFunction · 0.92
TestFormatFunction · 0.92
BenchmarkWrapFunction · 0.92
wrapNormalErrFunction · 0.92
Example_treeFunction · 0.92
f1Function · 0.92
f2Function · 0.92

Calls 2

GetCallerFunction · 0.92
wrapFunction · 0.70

Tested by 15

TestWrapNilFunction · 0.74
TestWrappedErrorFunction · 0.74
TestWrappedErrorIsFunction · 0.74
TestWrappedErrorAsFunction · 0.74
TestFormatTraceFunction · 0.74
TestFormatVerbsFunction · 0.74
TestFormatFunction · 0.74
BenchmarkWrapFunction · 0.74
wrapNormalErrFunction · 0.74
Example_treeFunction · 0.74
f1Function · 0.74
f2Function · 0.74