Error returns the aggregated error using errors.Join Returns nil if no errors were collected
()
| 249 | // Error returns the aggregated error using errors.Join |
| 250 | // Returns nil if no errors were collected |
| 251 | func (c *ErrorCollector) Error() error { |
| 252 | if len(c.errors) == 0 { |
| 253 | return nil |
| 254 | } |
| 255 | |
| 256 | if errorAggregationLog.Enabled() { |
| 257 | errorAggregationLog.Printf("Aggregating %d errors", len(c.errors)) |
| 258 | } |
| 259 | |
| 260 | if len(c.errors) == 1 { |
| 261 | return c.errors[0] |
| 262 | } |
| 263 | |
| 264 | return errors.Join(c.errors...) |
| 265 | } |
| 266 | |
| 267 | // FormattedError returns the aggregated error with a formatted header showing the count |
| 268 | // Returns nil if no errors were collected |