Calls a function in protected mode.
To call a function you must use the following protocol: first, the
function to be called is pushed onto the stack; then, the arguments
to the function are pushed in direct order; that is, the first
argument is pushed first. Finally you call lua_pcall; nargs is
the number of arguments that you pushed onto the stack. All arguments
and the function value are popped from the stack when the function is
called. The function results are pushed onto the stack when the
function returns. The number of results is adjusted to nresults,
unless nresults is Lua.LUA_MULTRET. In this case, all
results from the function are pushed. Lua takes care that the
returned values fit into the stack space. The function results are
pushed onto the stack in direct order (the first result is pushed
first), so that after the call the last result is on the top of the
stack.
If there is any error, lua_pcall catches it, pushes a single value
on the stack (the error message), and returns the error code.
lua_pcall always removes the function and its arguments from the
stack.
If msgh is 0, then the error object returned on the stack is
exactly the original error object. Otherwise, msgh is the location
of a message handler. (This index cannot be a pseudo-index.) In case
of runtime errors, this function will be called with the error object
and its return value will be the object returned on the stack by
lua_pcall.
Typically, the message handler is used to add more debug information
to the error object, such as a stack traceback. Such information
cannot be gathered after the return of lua_pcall, since by then
the stack has unwound.
https://www.lua.org/manual/5.4/manual.html#lua_pcall.