MCPcopy
hub / github.com/pkg/errors / Wrapf

Function Wrapf

errors.go:201–213  ·  view source on GitHub ↗

Wrapf returns an error annotating err with a stack trace at the point Wrapf is called, and the format specifier. If err is nil, Wrapf returns nil.

(err error, format string, args ...interface{})

Source from the content-addressed store, hash-verified

199// at the point Wrapf is called, and the format specifier.
200// If err is nil, Wrapf returns nil.
201func Wrapf(err error, format string, args ...interface{}) error {
202 if err == nil {
203 return nil
204 }
205 err = &withMessage{
206 cause: err,
207 msg: fmt.Sprintf(format, args...),
208 }
209 return &withStack{
210 err,
211 callers(),
212 }
213}
214
215// WithMessage annotates err with a new message.
216// If err is nil, WithMessage returns nil.

Callers 6

TestFormatWrapfFunction · 0.85
TestFormatWithStackFunction · 0.85
TestFormatGenericFunction · 0.85
TestWrapfNilFunction · 0.85
TestWrapfFunction · 0.85
TestErrorEqualityFunction · 0.85

Calls 1

callersFunction · 0.85

Tested by 6

TestFormatWrapfFunction · 0.68
TestFormatWithStackFunction · 0.68
TestFormatGenericFunction · 0.68
TestWrapfNilFunction · 0.68
TestWrapfFunction · 0.68
TestErrorEqualityFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…