Attributes returns the attributes of the errors, if they implement Attributes(). If more than one error is passed, subsequent error attributes will be added if not set.
(err ...error)
| 161 | // Attributes returns the attributes of the errors, if they implement Attributes(). |
| 162 | // If more than one error is passed, subsequent error attributes will be added if not set. |
| 163 | func Attributes(err ...error) map[string]any { |
| 164 | attributes := make(map[string]any) |
| 165 | for _, err := range err { |
| 166 | if attrErr := (attributer)(nil); errors.As(err, &attrErr) { |
| 167 | for k, v := range attrErr.Attributes() { |
| 168 | if _, ok := attributes[k]; !ok { |
| 169 | attributes[k] = v |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | return attributes |
| 175 | } |
| 176 | |
| 177 | // PublicAttributes returns the public attributes of the errors, if they implement PublicAttributes(). |
| 178 | // If more than one error is passed, subsequent error attributes will be added if not set. |