lua-users home
lua-l archive

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


>How can I go about handling errors that occur in the lua_dofile 
>function? If the function fails, it outputs to stderr (which I'd like 
>to prevent) and provides no indication that failure has occurred. Is 
>there any way I can suppress the output of the error message, discover 
>whether an error occurred, and retrieve the error string that would 
>normally be written to the console upon failure?

Yes, redefine _ALERT.

However, this works only for compatibility. In Lua 5.1, lua_dofile will be
removed and a luaL_dofile will be provided that works like lua_loadfile,
that is, it returns an error message on the stack in case of errors (be they
compilation or execution or another error).
--lhf