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...) --- manual/manual.of | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'manual') diff --git a/manual/manual.of b/manual/manual.of index 8b5e5d93..0e8e3d72 100644 --- a/manual/manual.of +++ b/manual/manual.of @@ -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,-} -- cgit v1.2.3-55-g6feb