Add adds an error to the collector If failFast is enabled, returns the error immediately Otherwise, adds it to the collection and returns nil
(err error)
| 222 | // If failFast is enabled, returns the error immediately |
| 223 | // Otherwise, adds it to the collection and returns nil |
| 224 | func (c *ErrorCollector) Add(err error) error { |
| 225 | if err == nil { |
| 226 | return nil |
| 227 | } |
| 228 | |
| 229 | if errorAggregationLog.Enabled() { |
| 230 | errorAggregationLog.Printf("Adding error to collector: %v", err) |
| 231 | } |
| 232 | |
| 233 | if c.failFast { |
| 234 | if errorAggregationLog.Enabled() { |
| 235 | errorAggregationLog.Print("Fail-fast enabled, returning error immediately") |
| 236 | } |
| 237 | return err |
| 238 | } |
| 239 | |
| 240 | c.errors = append(c.errors, err) |
| 241 | return nil |
| 242 | } |
| 243 | |
| 244 | // Count returns the number of errors collected |
| 245 | func (c *ErrorCollector) Count() int { |