MCPcopy Index your code
hub / github.com/chain/txvm / wrap

Function wrap

errors/errors.go:43–59  ·  view source on GitHub ↗

wrap adds a context message and stack trace to err and returns a new error containing the new context. This function is meant to be composed within other exported functions, such as Wrap and WithDetail. The argument stackSkip is the number of stack frames to ascend when generating stack straces, whe

(err error, msg string, stackSkip int)

Source from the content-addressed store, hash-verified

41// The argument stackSkip is the number of stack frames to ascend when
42// generating stack straces, where 0 is the caller of wrap.
43func wrap(err error, msg string, stackSkip int) error {
44 if err == nil {
45 return nil
46 }
47
48 werr, ok := err.(wrapperError)
49 if !ok {
50 werr.root = err
51 werr.msg = err.Error()
52 werr.stack = getStack(stackSkip+2, stackTraceSize)
53 }
54 if msg != "" {
55 werr.msg = msg + ": " + werr.msg
56 }
57
58 return werr
59}
60
61// Wrap adds a context message and stack trace to err and returns a new error
62// with the new context. Arguments are handled as in fmt.Print.

Callers 5

WrapFunction · 0.85
WrapfFunction · 0.85
WithDetailFunction · 0.85
WithDetailfFunction · 0.85
withDataFunction · 0.85

Calls 2

getStackFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected