(d hcl.Diagnostics)
| 116 | } |
| 117 | |
| 118 | func DiagnosticsErrorString(d hcl.Diagnostics) string { |
| 119 | count := len(d) |
| 120 | switch { |
| 121 | case count == 0: |
| 122 | return "no diagnostics" |
| 123 | case count == 1: |
| 124 | return DiagnosticErrorString(d[0]) |
| 125 | default: |
| 126 | for _, d := range d { |
| 127 | // Render the first error diag. |
| 128 | // If there are warnings, do not priority them over errors. |
| 129 | if d.Severity == hcl.DiagError { |
| 130 | return fmt.Sprintf("%s, and %d other diagnostic(s)", DiagnosticErrorString(d), count-1) |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | // All warnings? ok... |
| 135 | return fmt.Sprintf("%s, and %d other diagnostic(s)", DiagnosticErrorString(d[0]), count-1) |
| 136 | } |
| 137 | } |
no test coverage detected