MCPcopy Create free account
hub / github.com/juju/errors / Wrap

Function Wrap

functions.go:143–150  ·  view source on GitHub ↗

Wrap changes the Cause of the error. The location of the Wrap call is also stored in the error stack. For example: if err := SomeFunc(); err != nil { newErr := &packageError{"more context", private_value} return errors.Wrap(err, newErr) }

(other, newDescriptive error)

Source from the content-addressed store, hash-verified

141// }
142//
143func Wrap(other, newDescriptive error) error {
144 err := &Err{
145 previous: other,
146 cause: newDescriptive,
147 }
148 err.SetLocation(1)
149 return err
150}
151
152// Wrapf changes the Cause of the error, and adds an annotation. The location
153// of the Wrap call is also stored in the error stack.

Callers 7

TestWrapMethod · 0.92
TestWrapOfNilMethod · 0.92
TestCauseMethod · 0.92
TestErrorStackMethod · 0.92
TestAsMethod · 0.92
TestIsMethod · 0.92
TestErrorStringMethod · 0.92

Calls 1

SetLocationMethod · 0.95

Tested by 7

TestWrapMethod · 0.74
TestWrapOfNilMethod · 0.74
TestCauseMethod · 0.74
TestErrorStackMethod · 0.74
TestAsMethod · 0.74
TestIsMethod · 0.74
TestErrorStringMethod · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…