Last active
August 29, 2015 14:00
-
-
Save nefftd/11382745 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- depends on tostringall() https://gist.github.com/nefftd/11382819 | |
-- see: line 15 | |
do | |
local err_fmt = "bad argument #%d to '%s' (%s expected, got %s)" | |
local function checktypelist(t,a1,...) | |
if a1 then | |
return t == a1 or checktypelist(t,...) | |
end | |
end | |
function argcheck(val,argn,...) | |
local t = type(val) | |
if not checktypelist(t,...) then | |
local types = table.concat({tostringall(...)},'/') | |
local fname = debug.getinfo(2,'n').name or 'unknown' | |
argn = tonumber(argn) or 0 | |
error(err_fmt:format(argn,fname,types,t),3) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment