FormattedError returns the aggregated error with a formatted header showing the count Returns nil if no errors were collected This method is preferred over Error() + FormatAggregatedError for better accuracy
(category string)
| 268 | // Returns nil if no errors were collected |
| 269 | // This method is preferred over Error() + FormatAggregatedError for better accuracy |
| 270 | func (c *ErrorCollector) FormattedError(category string) error { |
| 271 | if len(c.errors) == 0 { |
| 272 | return nil |
| 273 | } |
| 274 | |
| 275 | if errorAggregationLog.Enabled() { |
| 276 | errorAggregationLog.Printf("Formatting %d errors for category: %s", len(c.errors), category) |
| 277 | } |
| 278 | |
| 279 | if len(c.errors) == 1 { |
| 280 | return c.errors[0] |
| 281 | } |
| 282 | |
| 283 | header := fmt.Sprintf("Found %d %s errors:", len(c.errors), category) |
| 284 | return fmt.Errorf("%s\n%w", header, errors.Join(c.errors...)) |
| 285 | } |
| 286 | |
| 287 | var sharedWorkflowLog = logger.New("workflow:shared_workflow_error") |
| 288 |