Handle errors

This commit is contained in:
Mikhail Mazurskiy
2021-06-05 09:43:13 +10:00
parent 0305860078
commit a3ed120efb
25 changed files with 232 additions and 126 deletions

View File

@@ -213,7 +213,10 @@ func String(node *yaml.Node, opts ...string) (string, error) {
b := &bytes.Buffer{}
e := NewEncoder(b)
err := e.Encode(node)
e.Close()
errClose := e.Close()
if err == nil {
err = errClose
}
val := b.String()
if optsSet.Has(Trim) {
val = strings.TrimSpace(val)