| 173 | */ |
| 174 | |
| 175 | LUALIB_API int luaL_argerror (lua_State *L, int arg, const char *extramsg) { |
| 176 | lua_Debug ar; |
| 177 | if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ |
| 178 | return luaL_error(L, "bad argument #%d (%s)", arg, extramsg); |
| 179 | lua_getinfo(L, "n", &ar); |
| 180 | if (strcmp(ar.namewhat, "method") == 0) { |
| 181 | arg--; /* do not count 'self' */ |
| 182 | if (arg == 0) /* error is in the self argument itself? */ |
| 183 | return luaL_error(L, "calling '%s' on bad self (%s)", |
| 184 | ar.name, extramsg); |
| 185 | } |
| 186 | if (ar.name == NULL) |
| 187 | ar.name = (pushglobalfuncname(L, &ar)) ? lua_tostring(L, -1) : "?"; |
| 188 | return luaL_error(L, "bad argument #%d to '%s' (%s)", |
| 189 | arg, ar.name, extramsg); |
| 190 | } |
| 191 | |
| 192 | |
| 193 | int luaL_typeerror (lua_State *L, int arg, const char *tname) { |
no test coverage detected