summaryrefslogtreecommitdiffhomepage
path: root/libs/cbi/luasrc/cbi.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-07-31 00:13:24 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-07-31 00:13:24 +0000
commitf311d13ca16e079e6e9c68bc1c62fb6e94400ee5 (patch)
tree2f0663e3eb3793bdf8f6951aabf1745071080c9f /libs/cbi/luasrc/cbi.lua
parent45d9fe0b165467b808bf2fa56edb9e9ebaa89c7b (diff)
libs/cbi: fix error reporting in map loading
Diffstat (limited to 'libs/cbi/luasrc/cbi.lua')
-rw-r--r--libs/cbi/luasrc/cbi.lua21
1 files changed, 11 insertions, 10 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua
index db76e3b92..83f5c27e7 100644
--- a/libs/cbi/luasrc/cbi.lua
+++ b/libs/cbi/luasrc/cbi.lua
@@ -60,17 +60,18 @@ function load(cbimap, ...)
local upldir = "/lib/uci/upload/"
local cbidir = luci.util.libpath() .. "/model/cbi/"
-
- assert(fs.stat(cbimap) or
- fs.stat(cbidir..cbimap..".lua") or
- fs.stat(cbidir..cbimap..".lua.gz"),
- "Model not found!")
-
- local func, err = loadfile(cbimap)
- if not func then
- func, err = loadfile(cbidir..cbimap..".lua") or
- loadfile(cbidir..cbimap..".lua.gz")
+ local func, err
+
+ if fs.access(cbimap) then
+ func, err = loadfile(cbimap)
+ elseif fs.access(cbidir..cbimap..".lua") then
+ func, err = loadfile(cbidir..cbimap..".lua")
+ elseif fs.access(cbidir..cbimap..".lua.gz") then
+ func, err = loadfile(cbidir..cbimap..".lua.gz")
+ else
+ func, err = nil, "Model '" .. cbimap .. "' not found!"
end
+
assert(func, err)
luci.i18n.loadc("cbi")