MCPcopy
hub / github.com/tinylib/msgp / WrapError

Function WrapError

msgp/errors.go:80–89  ·  view source on GitHub ↗

WrapError wraps an error with additional context that allows the part of the serialized type that caused the problem to be identified. Underlying errors can be retrieved using Cause() The input error is not modified - a new error should be returned. ErrShortBytes is not wrapped with any context du

(err error, ctx ...any)

Source from the content-addressed store, hash-verified

78// ErrShortBytes is not wrapped with any context due to backward compatibility
79// issues with the public API.
80func WrapError(err error, ctx ...any) error {
81 switch e := err.(type) {
82 case errShort:
83 return e
84 case contextError:
85 return e.withContext(ctxString(ctx))
86 default:
87 return errWrapped{cause: err, ctx: ctxString(ctx)}
88 }
89}
90
91func addCtx(ctx, add string) string {
92 if ctx != "" {

Callers 7

TestWrapResumableErrorFunction · 0.85
TestWrapMultipleFunction · 0.85
TestCauseFunction · 0.85
TestCauseShortByteFunction · 0.85
TestUnwrapFunction · 0.85

Calls 2

ctxStringFunction · 0.70
withContextMethod · 0.65

Tested by 7

TestWrapResumableErrorFunction · 0.68
TestWrapMultipleFunction · 0.68
TestCauseFunction · 0.68
TestCauseShortByteFunction · 0.68
TestUnwrapFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…