MCPcopy Create free account
hub / github.com/DoNewsCode/core / Wrap

Function Wrap

unierr/error.go:46–59  ·  view source on GitHub ↗

Wrap annotates an error with a codes.Code

(err error, code codes.Code)

Source from the content-addressed store, hash-verified

44
45// Wrap annotates an error with a codes.Code
46func Wrap(err error, code codes.Code) *Error {
47 if err == nil {
48 return &Error{
49 msg: code.String(),
50 code: code,
51 }
52 }
53 err = errors.WithStack(err)
54 return &Error{
55 err: err,
56 code: code,
57 msg: err.Error(),
58 }
59}
60
61// Wrapf annotates an error with a codes.Code, and provides a new error message.
62// The wrapped error hence is mainly kept for tracing and debugging. The message

Callers 6

ExampleFunction · 0.92
ExampleError_StatusCodeFunction · 0.92
ExampleError_GRPCStatusFunction · 0.92
WrapfFunction · 0.85
errFunction · 0.85
TestWrapFunction · 0.85

Calls 2

StringMethod · 0.65
ErrorMethod · 0.45

Tested by 4

ExampleFunction · 0.74
ExampleError_StatusCodeFunction · 0.74
ExampleError_GRPCStatusFunction · 0.74
TestWrapFunction · 0.68