Helper for determining if a Diagnostics contains errors
Checking if it's non-nil, as we would for Go errors, doesn't work here because there may be warnings.
This commit is contained in:
parent
8dfc3c4bbe
commit
b5a78fd826
@ -84,3 +84,14 @@ func (d Diagnostics) Append(diag *Diagnostic) Diagnostics {
|
|||||||
func (d Diagnostics) Extend(diags Diagnostics) Diagnostics {
|
func (d Diagnostics) Extend(diags Diagnostics) Diagnostics {
|
||||||
return append(d, diags...)
|
return append(d, diags...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasErrors returns true if the receiver contains any diagnostics of
|
||||||
|
// severity DiagError.
|
||||||
|
func (d Diagnostics) HasErrors() bool {
|
||||||
|
for _, diag := range d {
|
||||||
|
if diag.Severity == DiagError {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user