BuildPrioritizedErrorReportFromMessages classifies, suppresses, and limits messages.
(messages []string, showAll bool)
| 123 | |
| 124 | // BuildPrioritizedErrorReportFromMessages classifies, suppresses, and limits messages. |
| 125 | func BuildPrioritizedErrorReportFromMessages(messages []string, showAll bool) PrioritizedErrorReport { |
| 126 | errorRecoveryLog.Printf("Building prioritized error report: message_count=%d, show_all=%v", len(messages), showAll) |
| 127 | prioritized, suppressedCount := prioritizeErrorMessages(messages) |
| 128 | displayed := prioritized |
| 129 | if !showAll && len(displayed) > 5 { |
| 130 | errorRecoveryLog.Printf("Truncating displayed errors from %d to top 5 (set show_all=true to see all)", len(displayed)) |
| 131 | displayed = displayed[:5] |
| 132 | } |
| 133 | |
| 134 | report := PrioritizedErrorReport{ |
| 135 | TotalCount: len(prioritized), |
| 136 | DisplayedErrors: displayed, |
| 137 | HiddenCount: len(prioritized) - len(displayed), |
| 138 | SuppressedCount: suppressedCount, |
| 139 | } |
| 140 | if len(prioritized) > 1 { |
| 141 | report.RecoveryPlan = buildRecoveryPlan(prioritized, suppressedCount) |
| 142 | } |
| 143 | |
| 144 | errorRecoveryLog.Printf("Prioritized report ready: total=%d, displayed=%d, hidden=%d, suppressed=%d, has_plan=%v", |
| 145 | report.TotalCount, len(report.DisplayedErrors), report.HiddenCount, report.SuppressedCount, report.RecoveryPlan != nil) |
| 146 | return report |
| 147 | } |
| 148 | |
| 149 | func prioritizeErrorMessages(messages []string) ([]PrioritizedError, int) { |
| 150 | candidates := make([]PrioritizedError, 0, len(messages)) |