Tutorial by Examples

pcall stands for "protected call". It is used to add error handling to functions. pcall works similar as try-catch in other languages. The advantage of pcall is that the whole execution of the script is not being interrupted if errors occur in functions called with pcall. If an error insid...
Assuming we have the following function: function foo(tab) return tab.a end -- Script execution errors out w/ a stacktrace when tab is not a table Let's improve it a bit function foo(tab) if type(tab) ~= "table" then error("Argument 1 is not a table!", 2) end ...

Page 1 of 1