MCPcopy
hub / github.com/gogf/gf / Wrapf

Function Wrapf

errors/gerror/gerror_api.go:70–81  ·  view source on GitHub ↗

Wrapf returns an error annotating err with a stack trace at the point Wrapf is called, and the format specifier. It returns nil if given `err` is nil. Note that it does not lose the error code of wrapped error, as it inherits the error code from it.

(err error, format string, args ...any)

Source from the content-addressed store, hash-verified

68// It returns nil if given `err` is nil.
69// Note that it does not lose the error code of wrapped error, as it inherits the error code from it.
70func Wrapf(err error, format string, args ...any) error {
71 if err == nil {
72 return nil
73 }
74 return &Error{
75 error: err,
76 stack: callers(),
77 text: format,
78 args: args,
79 code: Code(err),
80 }
81}
82
83// WrapSkip wraps error with text. It returns nil if given err is nil.
84// The parameter `skip` specifies the stack callers skipped amount.

Callers 15

doRegisterLeaseMethod · 0.92
RegisterMethod · 0.92
DeregisterMethod · 0.92
ensureNameMethod · 0.92
ProceedMethod · 0.92
getServicesByPrefixMethod · 0.92
SearchMethod · 0.92
NewFunction · 0.92
doCommandMethod · 0.92
ReceiveMethod · 0.92
CloseMethod · 0.92
HandleResponseMethod · 0.92

Calls 2

callersFunction · 0.85
CodeFunction · 0.70

Tested by 3

Test_WrapfFunction · 0.74
Test_TextArgsFunction · 0.74
Benchmark_WrapfFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…