Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Xmair on Oct 31, 2015, 05:47 AM

Title: Line
Post by: Xmair on Oct 31, 2015, 05:47 AM
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!
Title: Re: Line
Post by: KAKAN on Oct 31, 2015, 07:00 AM
I think no, there's no way to do an EchoMessage with the exact line.
If yes, then I need it too.
Title: Re: Line
Post by: karan20000000000 on Oct 31, 2015, 07:13 AM
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.
Title: Re: Line
Post by: KAKAN on Oct 31, 2015, 07:34 AM
Wow.
Thanks a lot.
Title: Re: Line
Post by: Thijn on Oct 31, 2015, 08:17 AM
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 :)
Title: Re: Line
Post by: Stormeus on Oct 31, 2015, 08:55 AM
I'm convinced that there's a better way to write that code and that I just haven't figured it out yet.
Title: Re: Line
Post by: Xmair on Oct 31, 2015, 09:23 AM
Thanks, Marked as solved and locked.