error implementation, so that sets of diagnostics can be returned via APIs that normally deal in vanilla Go errors.
()
| 105 | // error implementation, so that sets of diagnostics can be returned via |
| 106 | // APIs that normally deal in vanilla Go errors. |
| 107 | func (d Diagnostics) Error() string { |
| 108 | count := len(d) |
| 109 | switch count { |
| 110 | case 0: |
| 111 | return "no diagnostics" |
| 112 | case 1: |
| 113 | return d[0].Error() |
| 114 | default: |
| 115 | return fmt.Sprintf("%s, and %d other diagnostic(s)", d[0].Error(), count-1) |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | // Append appends a new error to a Diagnostics and return the whole Diagnostics. |
| 120 | // |