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...)
This commit is contained in:
@@ -4979,6 +4979,19 @@ This function never returns.
|
||||
|
||||
}
|
||||
|
||||
@APIEntry{
|
||||
void luaL_argexpected (lua_State *L,
|
||||
int cond,
|
||||
int arg,
|
||||
const char *tname);|
|
||||
@apii{0,0,v}
|
||||
|
||||
Checks whether @id{cond} is true.
|
||||
If it is not, raises an error about the type of the argument @id{arg}
|
||||
with a standard message @seeF{luaL_typeerror}.
|
||||
|
||||
}
|
||||
|
||||
@APIEntry{typedef struct luaL_Buffer luaL_Buffer;|
|
||||
|
||||
Type for a @def{string buffer}.
|
||||
@@ -5713,6 +5726,19 @@ to start the traceback.
|
||||
|
||||
}
|
||||
|
||||
@APIEntry{const char *luaL_typeerror (lua_State *L,
|
||||
int arg,
|
||||
const char *tname);|
|
||||
@apii{0,0,v}
|
||||
|
||||
Raises a type error for argument @id{arg}
|
||||
of the @N{C function} that called it,
|
||||
using a standard message;
|
||||
@id{tname} is a @Q{name} for the expected type.
|
||||
This function never returns.
|
||||
|
||||
}
|
||||
|
||||
@APIEntry{const char *luaL_typename (lua_State *L, int index);|
|
||||
@apii{0,0,-}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user