diff options
-rw-r--r-- | src/lua_typeerror.c | 10 | ||||
-rw-r--r-- | src/lua_typeerror.h | 7 |
2 files changed, 17 insertions, 0 deletions
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 @@ | |||
1 | #include "lua_typeerror.h" | ||
2 | #include "lua.h" | ||
3 | #include "lauxlib.h" | ||
4 | |||
5 | int luaL_typeerror (lua_State *L, int narg, const char *tname) | ||
6 | { | ||
7 | const char *msg = lua_pushfstring(L, "%s expected, got %s",tname, luaL_typename(L, narg)); | ||
8 | return luaL_argerror(L, narg, msg); | ||
9 | } | ||
10 | |||
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 @@ | |||
1 | #ifndef LUA_TYPEERROR_H_ | ||
2 | #define LUA_TYPEERROR_H_ | ||
3 | |||
4 | struct lua_State; | ||
5 | int luaL_typeerror (struct lua_State *L, int narg, const char *tname); | ||
6 | |||
7 | #endif | ||