Err flattens a diagnostics list into a single Go error, or to nil if the diagnostics list does not include any error-level diagnostics. This can be used to smuggle diagnostics through an API that deals in native errors, but unfortunately it will lose any warnings that aren't accompanied by at least
()
| 157 | // |
| 158 | // return result, diags.Error() |
| 159 | func (diags Diagnostics) Err() error { |
| 160 | if !diags.HasErrors() { |
| 161 | return nil |
| 162 | } |
| 163 | return diagnosticsAsError{diags} |
| 164 | } |
| 165 | |
| 166 | // ErrWithWarnings is similar to Err except that it will also return a non-nil |
| 167 | // error if the receiver contains only warnings. |