Optimized error handling
This commit is contained in:
parent
2cde638a53
commit
cac36db080
1 changed files with 4 additions and 20 deletions
|
@ -464,18 +464,10 @@ function cbi(model)
|
||||||
require("luci.cbi")
|
require("luci.cbi")
|
||||||
require("luci.template")
|
require("luci.template")
|
||||||
|
|
||||||
local stat, maps = luci.util.copcall(luci.cbi.load, model, ...)
|
maps = luci.cbi.load(model, ...)
|
||||||
if not stat then
|
|
||||||
error500(maps)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
for i, res in ipairs(maps) do
|
for i, res in ipairs(maps) do
|
||||||
local stat, err = luci.util.copcall(res.parse, res)
|
res:parse()
|
||||||
if not stat then
|
|
||||||
error500(err)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
luci.template.render("cbi/header")
|
luci.template.render("cbi/header")
|
||||||
|
@ -493,18 +485,10 @@ function form(model)
|
||||||
require("luci.cbi")
|
require("luci.cbi")
|
||||||
require("luci.template")
|
require("luci.template")
|
||||||
|
|
||||||
local stat, maps = luci.util.copcall(luci.cbi.load, model, ...)
|
maps = luci.cbi.load(model, ...)
|
||||||
if not stat then
|
|
||||||
error500(maps)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
for i, res in ipairs(maps) do
|
for i, res in ipairs(maps) do
|
||||||
local stat, err = luci.util.copcall(res.parse, res)
|
res:parse()
|
||||||
if not stat then
|
|
||||||
error500(err)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
luci.template.render("header")
|
luci.template.render("header")
|
||||||
|
|
Loading…
Reference in a new issue