diff --git a/src/lua_typeerror.c b/src/lua_typeerror.c new file mode 100644 index 0000000..d6a3d76 --- /dev/null +++ b/src/lua_typeerror.c @@ -0,0 +1,10 @@ +#include "lua_typeerror.h" +#include "lua.h" +#include "lauxlib.h" + +int luaL_typeerror (lua_State *L, int narg, const char *tname) +{ + const char *msg = lua_pushfstring(L, "%s expected, got %s",tname, luaL_typename(L, narg)); + return luaL_argerror(L, narg, msg); +} + diff --git a/src/lua_typeerror.h b/src/lua_typeerror.h new file mode 100644 index 0000000..4f2aafd --- /dev/null +++ b/src/lua_typeerror.h @@ -0,0 +1,7 @@ +#ifndef LUA_TYPEERROR_H_ +#define LUA_TYPEERROR_H_ + +struct lua_State; +int luaL_typeerror (struct lua_State *L, int narg, const char *tname); + +#endif