Merge pull request #4497 from m-Bilal/fix-3812

Fix 3812; Error message changed and check for MalformedYamlError
This commit is contained in:
Natasha Sarkar
2022-03-24 09:55:44 -07:00
committed by GitHub
8 changed files with 63 additions and 6 deletions

View File

@@ -294,7 +294,7 @@ func (r *ByteReader) decode(originalYAML string, index int, decoder *yaml.Decode
return nil, io.EOF
}
if err != nil {
return nil, errors.Wrap(err)
return nil, errors.WrapPrefixf(err, "MalformedYAMLError")
}
if yaml.IsYNodeEmptyDoc(node) {

View File

@@ -673,7 +673,7 @@ apiVersion: example.com/v1beta1
`
_, err := FormatInput(strings.NewReader(y))
assert.EqualError(t, err, "yaml: line 15: found character that cannot start any token")
assert.EqualError(t, err, "MalformedYAMLError: yaml: line 15: found character that cannot start any token")
}
// TestFormatFileOrDirectory_yamlExtFile verifies that FormatFileOrDirectory will format a file