| 196 | |
| 197 | |
| 198 | static int typeerror(lua_State *L, int arg, const char *tname) { |
| 199 | const char *msg; |
| 200 | const char *typearg; /* name for the type of the actual argument */ |
| 201 | if (luaL_getmetafield(L, arg, "__name") == LUA_TSTRING) |
| 202 | typearg = lua_tostring(L, -1); /* use the given type name */ |
| 203 | else if (lua_type(L, arg) == LUA_TLIGHTUSERDATA) |
| 204 | typearg = "light userdata"; /* special name for messages */ |
| 205 | else |
| 206 | typearg = luaL_typename(L, arg); /* standard name */ |
| 207 | msg = lua_pushfstring(L, "%s expected, got %s", tname, typearg); |
| 208 | global_glua_chain_api->throw_exception(L, THINKYOUNG_API_SIMPLE_ERROR, msg); |
| 209 | return luaL_argerror(L, arg, msg); |
| 210 | } |
| 211 | |
| 212 | |
| 213 | static void tag_error(lua_State *L, int arg, int tag) { |
no test coverage detected