summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2015-12-28 16:20:17 +0000
committerTed Trask <ttrask01@yahoo.com>2015-12-28 16:20:17 +0000
commitfbe71548bafcf2bdcb85afe1ef0aa94b81a4c225 (patch)
tree423c6f3d20c3fdfc53d2e8c580cb448c240d8a4b
parent0e9d6d88d375f3ef9226ee053db819d671582e24 (diff)
downloadacf-provisioning-fbe71548bafcf2bdcb85afe1ef0aa94b81a4c225.tar.bz2
acf-provisioning-fbe71548bafcf2bdcb85afe1ef0aa94b81a4c225.tar.xz
Use cfe:print_errtxt in more places for better error reporting
-rw-r--r--provisioning-model.lua34
1 files changed, 5 insertions, 29 deletions
diff --git a/provisioning-model.lua b/provisioning-model.lua
index 2c54619..3fc0f50 100644
--- a/provisioning-model.lua
+++ b/provisioning-model.lua
@@ -1260,7 +1260,7 @@ mymodule.update_group = function(self, group, action, create)
-- Notify the devices that their params might have changed (this will also validate)
for i,d in ipairs(devices) do
local r = set_device_params(get_device_params(d.device_id, false), false)
- if r.errtxt then self.logevent("Failed to update params for device "..d.device_id..": "..r.errtxt) end
+ if r.errtxt then self.logevent("ERROR: Failed to update params for device "..d.device_id.."\n"..r:print_errtxt()) end
end
end
end)
@@ -1445,7 +1445,7 @@ mymodule.update_param = function(self, param, action, create)
-- Notify the devices that their params might have changed (this will also validate)
for i,d in ipairs(devices) do
local r = set_device_params(get_device_params(d.device_id, false), false)
- if r.errtxt then self.logevent("Failed to update params for device "..d.device_id..": "..r.errtxt) end
+ if r.errtxt then self.logevent("ERROR: Failed to update params for device "..d.device_id.."\n"..r:print_errtxt()) end
end
end
end)
@@ -2317,13 +2317,7 @@ mymodule.create_from_request = function(self, request)
device.value.classes.value[group].value = class
device = mymodule.create_device(self, device)
if device.errtxt then
- request.errtxt = {device.errtxt}
- for n,v in pairs(device.value) do
- if v.errtxt then
- request.errtxt[#request.errtxt + 1] = v.errtxt
- end
- end
- request.errtxt = table.concat(request.errtxt, "\n")
+ request.errtxt = device:print_errtxt()
else
local params = get_device_params(device.value.device_id.value)
-- Set the MAC Address
@@ -2464,14 +2458,7 @@ mymodule.bulk_create_devices = function(self, devicelist)
device = mymodule.update_device(self, device, "Create", true, true)
if device.errtxt then
- local err = {"Failed to create device in line "..i}
- err[#err+1] = device.errtxt
- for n,v in pairs(device.value) do
- if v.errtxt then
- err[#err + 1] = v.errtxt
- end
- end
- error(table.concat(err, "\n"))
+ error("Failed to create device in line "..i.."\n"..device:print_errtxt())
end
-- Set the params
@@ -2511,18 +2498,7 @@ mymodule.bulk_create_devices = function(self, devicelist)
params = set_device_params(params, false, true)
if params.errtxt then
- local err = {"Failed to create device in line "..i}
- err[#err+1] = params.errtxt
- for cname,cvalue in pairs(params.value) do
- if type(cvalue.value) == "table" then
- for pname,pvalue in pairs(cvalue.value) do
- if pvalue.errtxt then
- err[#err + 1] = cname.."."..pname..": "..pvalue.errtxt
- end
- end
- end
- end
- error(table.concat(err, "\n"))
+ error("Failed to create device in line "..i.."\n"..params:print_errtxt())
end
end
if connected then databasedisconnect() end