Merge pull request #39 from hashicorp/f-hcl-diag-as-errors

hcl: Add Diagnostics.Errs()
This commit is contained in:
Radek Simko 2018-07-03 18:58:32 +01:00 committed by GitHub
commit 2c946fb6e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,6 +96,17 @@ func (d Diagnostics) HasErrors() bool {
return false
}
func (d Diagnostics) Errs() []error {
var errs []error
for _, diag := range d {
if diag.Severity == DiagError {
errs = append(errs, diag)
}
}
return errs
}
// A DiagnosticWriter emits diagnostics somehow.
type DiagnosticWriter interface {
WriteDiagnostic(*Diagnostic) error