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.
()
| 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. |
| 154 | func (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 | |
| 174 | type errInfo struct { |
| 175 | Message string `json:"message"` |