From 099e97532cca6925282e79ebe267cc3b25e7aa4f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 30 Nov 2011 12:50:32 +0000 Subject: libs/web: add assert() statements for unresolvable function case --- libs/web/luasrc/dispatcher.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'libs/web/luasrc/dispatcher.lua') 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 -- cgit v1.2.3