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

Function Annotatef

functions.go:99–110  ·  view source on GitHub ↗

Annotatef is used to add extra context to an existing error. The location of the Annotate call is recorded with the annotations. The file, line and function are also recorded. For example: if err := SomeFunc(); err != nil { return errors.Annotatef(err, "failed to frombulate the %s", arg) }

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

Source from the content-addressed store, hash-verified

97// }
98//
99func Annotatef(other error, format string, args ...interface{}) error {
100 if other == nil {
101 return nil
102 }
103 err := &Err{
104 previous: other,
105 cause: Cause(other),
106 message: fmt.Sprintf(format, args...),
107 }
108 err.SetLocation(1)
109 return err
110}
111
112// DeferredAnnotatef annotates the given error (when it is not nil) with the given
113// format string and arguments (like fmt.Sprintf). If *err is nil, DeferredAnnotatef

Callers 4

TestAnnotatefMethod · 0.92
TestCauseMethod · 0.92
TestErrorStackMethod · 0.92
TestErrorStringMethod · 0.92

Calls 2

SetLocationMethod · 0.95
CauseFunction · 0.85

Tested by 4

TestAnnotatefMethod · 0.74
TestCauseMethod · 0.74
TestErrorStackMethod · 0.74
TestErrorStringMethod · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…