MCPcopy
hub / github.com/duke-git/lancet / Values

Method Values

xerror/xerror.go:154–172  ·  view source on GitHub ↗

Values returns map of key and value that is set by With. All wrapped xerror.XError key and values will be merged. Key and values of wrapped error is overwritten by upper xerror.XError.

()

Source from the content-addressed store, hash-verified

152// Values returns map of key and value that is set by With. All wrapped xerror.XError key and values will be merged.
153// Key and values of wrapped error is overwritten by upper xerror.XError.
154func (e *XError) Values() map[string]any {
155 var values map[string]any
156
157 if cause := e.Unwrap(); cause != nil {
158 if err, ok := cause.(*XError); ok {
159 values = err.Values()
160 }
161 }
162
163 if values == nil {
164 values = make(map[string]any)
165 }
166
167 for key, value := range e.values {
168 values[key] = value
169 }
170
171 return values
172}
173
174type errInfo struct {
175 Message string `json:"message"`

Callers 3

ExampleXError_WithFunction · 0.45
ExampleXError_ValuesFunction · 0.45

Calls 1

UnwrapMethod · 0.95

Tested by 3

ExampleXError_WithFunction · 0.36
ExampleXError_ValuesFunction · 0.36