Handles the error and print to console. You also can print to your own console.
Test code:
Output:
Code Select
function errorHandling(err)
{
local stackInfos = getstackinfos(2);
if (stackInfos)
{
local locals = "";
foreach( index, value in stackInfos.locals )
{
if( index != "this" )
locals = locals + "[" + index + "] " + value + "\n";
}
local callStacks = "";
local level = 2;
do {
callStacks += "*FUNCTION [" + stackInfos.func + "()] " + stackInfos.src + " line [" + stackInfos.line + "]\n";
level++;
} while ((stackInfos = getstackinfos(level)));
local errorMsg = "AN ERROR HAS OCCURRED [" + err + "]\n";
errorMsg += "\nCALLSTACK\n";
errorMsg += callStacks;
errorMsg += "\nLOCALS\n";
errorMsg += locals;
Console.Print(errorMsg);
}
}
seterrorhandler(errorHandling);
Code also can be found here: https://bitbucket.org/snippets/ysc3839/p64jGTest code:
Code Select
function Script::ScriptLoad()
{
local t = null;
Console.Print(t.t);
}
Output:
Code Select
AN ERROR HAS OCCURRED [the index 't' does not exist]
CALLSTACK
*FUNCTION [ScriptLoad()] Main Script line [37]
LOCALS
[this] (class : 0x0EEA1820)
[t] (null : 0x00000000)