Hey guys, I was wondering that is there any way to throw out the exact line of try{ catch(e) error to the Echo using EchoMessage or without using the try{ catch(e) error.
Any help will be appreciated!
I think no, there's no way to do an EchoMessage with the exact line.
If yes, then I need it too.
The actual code is by Thijn
function onScriptLoad()
{
seterrorhandler( errorHandling );
}
function errorHandling( obj )
{
local callingStack = getstackinfos( 2 );
local funcName = callingStack.func;
local origin = callingStack.src;
local lineNo = callingStack.line;
local locals = "";
foreach( index, value in callingStack.locals )
{
if( index != "this" )
locals = locals + "\t[" + index + "]: " + value + "\n";
}
EchoMessage( "Error occurring in " + origin + ": " + lineNo + ", function: " + funcName + "." );
EchoMessage( ">> " + obj + "\n" );
EchoMessage( locals );
}
Note: seterrorhandler is built-in function. Make sure the EchoMessage function is defined in your script.
Wow.
Thanks a lot.
Just to make clear, since I hate taking credit for something not made by me, that snippet is made by
@Stormeus. I posted it ages ago on the old forum, I think :)
I'm convinced that there's a better way to write that code and that I just haven't figured it out yet.
Thanks, Marked as solved and locked.