Executes a function in protected mode. When running a function in protected mode, any errors do not propagate beyond the function (i.e. they do not stop all execution and call the default error handler).

See also Lua library functions.


status, ... = pcall(f, ...)


  • f - A function (function)
  • ... - Arguments to be passed to the function (list)


  • status - True if the function succeeded without errors; false otherwise (boolean)
  • ... - If status is false, the error message produced by the function; if status is true, the return values from the function (list or string)
This function is defined in the Lua standard libraries