xpcall

From Garry's Mod
Revision as of 15:27, 24 January 2014 by Robotboy655 (Talk | contribs)
Jump to: navigation, search
 xpcall( )

Contents

Description

Attempts to call the first function, if the execution fails, the second function is called with the error message, unlike in pcall the stack is not unwinded and can therefore be used to stack analyses using debug.getinfo, the disadvantage of this function is, that it does not allow passing argument to the to be called function.

Arguments

function func

Numbers to get the largest from

Arguments

function errorCallback

Function to be called on error, error message passed as parameter

Arguments

vararg arguments

Arguments to call the function with

Examples

Example

Catch an error.

local succ, arg1= xpcall(function() aisj() end, function(err) print("ERROR:", err) end)
print(succ)

Output:

ERROR: SOURCE attempt to call global 'aisj' (a nil value)
false
Personal tools
Navigation