lua-users home
lua-l archive

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



> It seems to me that it would be simpler to set a global error handling
> function than to specify it for every call to lua_pcall?

You can just put the error function on the stack once, and then use it
in each call to lua_pcall. It does not get consumed by lua_pcall.

On the other hand, if you have a series of pcalls with the same error
function, it is quite possible that you can refactor that to a single
pcall, which wraps the function which does the series of calls.

This is particularly useful if the purpose of the pcall is simply
to hide the end of the call stack, or add extra information to it
(like the position in an input file, for example.)