X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=libs%2Fweb%2Fluasrc%2Fdispatcher.lua;fp=libs%2Fweb%2Fluasrc%2Fdispatcher.lua;h=7c77f2e97a4c85c15154b4cb6757428391e95eb1;hp=911f2f4e9a59e3ae9fe592a3d410ebbb138af039;hb=099e97532cca6925282e79ebe267cc3b25e7aa4f;hpb=c5329d85d5a3f4ac14d0a07b298167876d979413 diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua index 911f2f4e9..7c77f2e97 100644 --- a/libs/web/luasrc/dispatcher.lua +++ b/libs/web/luasrc/dispatcher.lua @@ -761,10 +761,18 @@ end local function _call(self, ...) + local func = getfenv()[self.name] + assert(func ~= nil, + 'Cannot resolve function "' .. self.name .. '". Is it misspelled or local?') + + assert(type(func) == "function", + 'The symbol "' .. self.name .. '" does not refer to a function but data ' .. + 'of type "' .. type(func) .. '".') + if #self.argv > 0 then - return getfenv()[self.name](unpack(self.argv), ...) + return func(unpack(self.argv), ...) else - return getfenv()[self.name](...) + return func(...) end end