mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-10 00:05:38 +00:00
Return error instead of panic in Lua encoder
This commit is contained in:
parent
f544580692
commit
58d14f7ea9
@ -1,6 +1,7 @@
|
||||
package yqlib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
@ -183,7 +184,7 @@ func (le *luaEncoder) encodeAny(writer io.Writer, node *yaml.Node) error {
|
||||
return writeString(writer, strings.ToLower(node.Value))
|
||||
case "!!int":
|
||||
if strings.HasPrefix(node.Value, "0o") {
|
||||
panic("Lua encoder NYI -- octal") // FIXME
|
||||
return fmt.Errorf("Lua encoder NYI -- octal") // FIXME
|
||||
}
|
||||
return writeString(writer, strings.ToLower(node.Value))
|
||||
case "!!float":
|
||||
@ -198,7 +199,7 @@ func (le *luaEncoder) encodeAny(writer io.Writer, node *yaml.Node) error {
|
||||
return writeString(writer, node.Value)
|
||||
}
|
||||
default:
|
||||
panic("Lua encoder NYI -- " + node.ShortTag())
|
||||
return fmt.Errorf("Lua encoder NYI -- %s", node.ShortTag())
|
||||
}
|
||||
case yaml.DocumentNode:
|
||||
err := writeString(writer, le.docPrefix)
|
||||
@ -211,7 +212,7 @@ func (le *luaEncoder) encodeAny(writer io.Writer, node *yaml.Node) error {
|
||||
}
|
||||
return writeString(writer, le.docSuffix)
|
||||
default:
|
||||
panic("Lua encoder NYI -- " + node.ShortTag())
|
||||
return fmt.Errorf("Lua encoder NYI -- %s", node.ShortTag())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user