aboutsummaryrefslogtreecommitdiff
path: root/ldblib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-12-10 13:46:03 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-12-10 13:46:03 -0200
commit46beca5bed8a7700b18100fe48a78373be5055f9 (patch)
tree499de35c048605434d9adb7ace964adf673041ac /ldblib.c
parent28d829c86712ce5bc453feccc5129a32f78d80c0 (diff)
downloadlua-46beca5bed8a7700b18100fe48a78373be5055f9.tar.gz
lua-46beca5bed8a7700b18100fe48a78373be5055f9.tar.bz2
lua-46beca5bed8a7700b18100fe48a78373be5055f9.zip
Better error messages for some polymorphic functions
New auxiliary functions/macros 'luaL_argexpected'/'luaL_typeerror' ease the creation of error messages such as bad argument #2 to 'setmetatable' (nil or table expected, got boolean) (The novelty being the "got boolean" part...)
Diffstat (limited to 'ldblib.c')
-rw-r--r--ldblib.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/ldblib.c b/ldblib.c
index 20010842..ada35250 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -55,8 +55,7 @@ static int db_getmetatable (lua_State *L) {
55 55
56static int db_setmetatable (lua_State *L) { 56static int db_setmetatable (lua_State *L) {
57 int t = lua_type(L, 2); 57 int t = lua_type(L, 2);
58 luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, 58 luaL_argexpected(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil or table");
59 "nil or table expected");
60 lua_settop(L, 2); 59 lua_settop(L, 2);
61 lua_setmetatable(L, 1); 60 lua_setmetatable(L, 1);
62 return 1; /* return 1st argument */ 61 return 1; /* return 1st argument */