Improve error handling in UCIDHCPConf

This commit is contained in:
Philippe Caseiro 2018-10-25 12:03:54 +02:00
parent 3282ef5f1b
commit 6f2598aff2
1 changed files with 11 additions and 0 deletions

View File

@ -36,6 +36,17 @@ func (dh *UCIDHCPConf) Create() *Action {
return result return result
} }
for key, value := range conf { for key, value := range conf {
fmt.Printf("DEBUG %s == %s\n", key, value)
if value == "" {
return &Action{
CommandResult: &CommandResult{
Stdout: "",
Stderr: fmt.Sprintf("dhcp.%s can't be empty", key),
ReturnCode: 100,
},
Command: "Empty value error",
}
}
result := uci.Set(fmt.Sprintf("dhcp.%s.%s", dh.Name, key), value) result := uci.Set(fmt.Sprintf("dhcp.%s.%s", dh.Name, key), value)
if result.ReturnCode != 0 { if result.ReturnCode != 0 {
return result return result