lua_pcall

Function lua_pcall 

Source
pub unsafe extern "C-unwind" fn lua_pcall(
    L: *mut lua_State,
    nargs: c_int,
    nresults: c_int,
    errfunc: c_int,
) -> lua_Status
Expand description

Calls a protected function on the stack, with the given number of arguments, and the given number of results.

This function is similar to lua_call, but in the case of an error, the error will be caught, the error value will be pushed onto the stack, and an error code will be returned.

If errfunc is not 0, it will be used as the index of the error handler function, which will be called with the error value on the stack and should return an error value. This function is usually used to add stack traces to errors, as the error handler function is called before the stack is unwound.

When the call is successful, the results will be pushed onto the stack, and the function will return LUA_OK.

When the call errors, the error handler, if it exists, will be called, the error value will be pushed to the stack, and the function will return LUA_ERRRUN, or if the error handler errored, LUA_ERRERR, or if there was an allocation error LUA_ERRMEM will be returned.

When the call yields, the function will return LUA_OK