lua-users home
lua-l archive

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


>I've been porting over my software to the 5.0 beta. So far I like what I've
>seen. However, I need to know more about where error messages and such are
>sent by Lua. 4.0 had _ALERT, which I redirected to my own C function, such
>that Lua error messages would be sent to my log system. The 5.0 reference
>manual says nothing about _ALERT, and doesn't seem to offer an alternative. Is
>there something I've missed?

There is no _ALERT in 5.0 because Lua 5.0 does not issue any error messages:
it leaves them on the stack to be handled by the application as it sees fit.
This scheme is simpler and more flexible. You have to check the return value
of lua_load, lua_pcall, or lua_cpcall (see etc/min.c for a simple example).
Or lua_loadfile or lua_loadstring if you're using them. For compatibility,
there is still lua_dofile and lua_dostring, which will try to call _ALERT,
but those 2 functions are for compatibility only.

Moreover, the standalone interpreter, lua.c, calls _TRACEBACK in case of errors.
This functions receives an error message and the intention is that it
reformats suitably and return the reformatted string, but _TRACEBACK can be
used to catch errors (however, lua.c will still print some error message).
--lhf