From 46beca5bed8a7700b18100fe48a78373be5055f9 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 10 Dec 2018 13:46:03 -0200 Subject: 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...) --- ldblib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'ldblib.c') 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) { static int db_setmetatable (lua_State *L) { int t = lua_type(L, 2); - luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, - "nil or table expected"); + luaL_argexpected(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil or table"); lua_settop(L, 2); lua_setmetatable(L, 1); return 1; /* return 1st argument */ -- cgit v1.2.3-55-g6feb