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

Function Wrap

error.go:93–115  ·  view source on GitHub ↗

Wrap 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 skip parameter indicates how far up the stack to start the stacktrace. 0 is from the current call, 1 from its caller, etc.

(e interface{}, skip int)

Source from the content-addressed store, hash-verified

91// fmt.Errorf("%v"). The skip parameter indicates how far up the stack
92// to start the stacktrace. 0 is from the current call, 1 from its caller, etc.
93func Wrap(e interface{}, skip int) *Error {
94 if e == nil {
95 return nil
96 }
97
98 var err error
99
100 switch e := e.(type) {
101 case *Error:
102 return e
103 case error:
104 err = e
105 default:
106 err = fmt.Errorf("%v", e)
107 }
108
109 stack := make([]uintptr, MaxStackDepth)
110 length := runtime.Callers(2+skip, stack[:])
111 return &Error{
112 Err: err,
113 stack: stack[:length],
114 }
115}
116
117// WrapPrefix makes an Error from the given value. If that value is already an
118// error then it will be used directly, if not, it will be passed to

Callers 8

WrapPrefixFunction · 0.85
ErrorfFunction · 0.85
TestAsFunction · 0.85
TestSkipWorksFunction · 0.85
TestWrapErrorFunction · 0.85
ExampleWrapErrorFunction · 0.85
ExampleWrapError_skipFunction · 0.85
ExampleWrapFunction · 0.85

Calls 1

CallersMethod · 0.80

Tested by 6

TestAsFunction · 0.68
TestSkipWorksFunction · 0.68
TestWrapErrorFunction · 0.68
ExampleWrapErrorFunction · 0.68
ExampleWrapError_skipFunction · 0.68
ExampleWrapFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…