lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


FWIW, here's the macro I'm using instead of lua_error or luaL_Error to
trackback to the proper level for reporting errors to users:

#define	SCRIPT_ERROR(L, level, string, ...)		
lua_getglobal(L, "error");					\												
lua_pushfstring(L, string, __VA_ARGS__);	\
lua_pushinteger(L, level);					\
lua_call(L, 2, 0);

test examples:
SCRIPT_ERROR(L, 4, "invalid argument 2 for jit.attribute, must be
string %d", 999);
SCRIPT_ERROR(L, 4, "invalid argument 2 for jit.attribute, must be
string", NULL);

You still have to provide a 4th argument to the macro, but it can be NULL.

wes