WoW:API pcall
Returns a boolean value to catch errors from the function call (func).
retVal = pcall (func, arg1, arg2, ...);
Parameters
Arguments
- (func, arg1, arg2, ...)
- func
- Function - The function that will be called (from within) pcall().
- arg1
- Variable - Any variable that is also to be passed with the function when its called (if any).
- arg2
- Variable - Same as arg1.
Returns
- Returns
- retVal
- retvaL
- Boolean - If the call to the function (that was passed to pcall) succeeded, returns true. If an error occured, returns false.
Example
function myTest() local strTest = "I am a string"; strTest = strTest + 10; end local retVal = pcall(myTest());
Result
pcall will catch the error that occured within 'myTest' and return false.
retVal = false;
Details
- pcall will also return other arguments returned from the "function" if all is successful.