PublicAttributes returns the public attributes of the errors, if they implement PublicAttributes(). If more than one error is passed, subsequent error attributes will be added if not set.
(err ...error)
| 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. |
| 179 | func PublicAttributes(err ...error) map[string]any { |
| 180 | attributes := make(map[string]any) |
| 181 | for _, err := range err { |
| 182 | if attrErr := (publicAttributer)(nil); errors.As(err, &attrErr) { |
| 183 | for k, v := range attrErr.PublicAttributes() { |
| 184 | if _, ok := attributes[k]; !ok { |
| 185 | attributes[k] = v |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | return attributes |
| 191 | } |