MCPcopy Index your code
hub / github.com/go-errors/errors / WrapPrefix

Function WrapPrefix

error.go:123–140  ·  view source on GitHub ↗

WrapPrefix makes an Error from the given value. If that value is already an error then it will be used directly, if not, it will be passed to fmt.Errorf("%v"). The prefix parameter is used to add a prefix to the error message when calling Error(). The skip parameter indicates how far up the stack to

(e interface{}, prefix string, skip int)

Source from the content-addressed store, hash-verified

121// up the stack to start the stacktrace. 0 is from the current call,
122// 1 from its caller, etc.
123func WrapPrefix(e interface{}, prefix string, skip int) *Error {
124 if e == nil {
125 return nil
126 }
127
128 err := Wrap(e, 1+skip)
129
130 if err.prefix != "" {
131 prefix = fmt.Sprintf("%s: %s", prefix, err.prefix)
132 }
133
134 return &Error{
135 Err: err.Err,
136 stack: err.stack,
137 prefix: prefix,
138 }
139
140}
141
142// Errorf creates a new error with the given message. You can use it
143// as a drop-in replacement for fmt.Errorf() to provide descriptive

Callers 1

TestWrapPrefixErrorFunction · 0.85

Calls 1

WrapFunction · 0.85

Tested by 1

TestWrapPrefixErrorFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…