From 6f2598aff2349b568945bd027a556f54f0d01931 Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Thu, 25 Oct 2018 12:03:54 +0200 Subject: [PATCH] Improve error handling in UCIDHCPConf --- uci_dhcp_conf.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/uci_dhcp_conf.go b/uci_dhcp_conf.go index 1fcb788..8823994 100644 --- a/uci_dhcp_conf.go +++ b/uci_dhcp_conf.go @@ -36,6 +36,17 @@ func (dh *UCIDHCPConf) Create() *Action { return result } 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) if result.ReturnCode != 0 { return result