Add adds an error to the errorSet.
(err error)
| 1244 | |
| 1245 | // Add adds an error to the errorSet. |
| 1246 | func (es *errorSet) Add(err error) { |
| 1247 | if err == nil { |
| 1248 | return |
| 1249 | } |
| 1250 | |
| 1251 | if len(es.errs) == 0 { |
| 1252 | es.errs = []error{err} |
| 1253 | } else { |
| 1254 | es.errs = append(es.errs, err) |
| 1255 | } |
| 1256 | if es.reasonSet == nil { |
| 1257 | es.reasonSet = make(map[string]struct{}) |
| 1258 | } |
| 1259 | |
| 1260 | switch addedErr := err.(type) { |
| 1261 | case *replicationErrors: |
| 1262 | for reason := range addedErr.reasonSet { |
| 1263 | es.reasonSet[reason] = struct{}{} |
| 1264 | } |
| 1265 | case *writeErrors: |
| 1266 | for reason := range addedErr.reasonSet { |
| 1267 | es.reasonSet[reason] = struct{}{} |
| 1268 | } |
| 1269 | default: |
| 1270 | es.reasonSet[err.Error()] = struct{}{} |
| 1271 | } |
| 1272 | } |
| 1273 | |
| 1274 | // writeErrors contains all errors that have |
| 1275 | // occurred during a local write of a remote-write request. |