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
|
package yqlib
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -183,7 +184,7 @@ func (le *luaEncoder) encodeAny(writer io.Writer, node *yaml.Node) error {
|
|||||||
return writeString(writer, strings.ToLower(node.Value))
|
return writeString(writer, strings.ToLower(node.Value))
|
||||||
case "!!int":
|
case "!!int":
|
||||||
if strings.HasPrefix(node.Value, "0o") {
|
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))
|
return writeString(writer, strings.ToLower(node.Value))
|
||||||
case "!!float":
|
case "!!float":
|
||||||
@ -198,7 +199,7 @@ func (le *luaEncoder) encodeAny(writer io.Writer, node *yaml.Node) error {
|
|||||||
return writeString(writer, node.Value)
|
return writeString(writer, node.Value)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
panic("Lua encoder NYI -- " + node.ShortTag())
|
return fmt.Errorf("Lua encoder NYI -- %s", node.ShortTag())
|
||||||
}
|
}
|
||||||
case yaml.DocumentNode:
|
case yaml.DocumentNode:
|
||||||
err := writeString(writer, le.docPrefix)
|
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)
|
return writeString(writer, le.docSuffix)
|
||||||
default:
|
default:
|
||||||
panic("Lua encoder NYI -- " + node.ShortTag())
|
return fmt.Errorf("Lua encoder NYI -- %s", node.ShortTag())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user