luaL_argcheck

void luaL_argcheck (lua_State *L,
                    int cond,
                    int numarg,
                    const char *extramsg);

Checks whether cond is true. If not, raises an error with the following message, where func is retrieved from the call stack:

     bad argument #<numarg> to <func> (<extramsg>)