Line

Started by Xmair, Oct 31, 2015, 05:47 AM

Previous topic - Next topic

Xmair

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!

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

KAKAN

I think no, there's no way to do an EchoMessage with the exact line.
If yes, then I need it too.
oh no

karan20000000000

#2
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.
With regards,
KP
------------------------------------------

KAKAN

Wow.
Thanks a lot.
oh no

Thijn

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 :)

Stormeus

I'm convinced that there's a better way to write that code and that I just haven't figured it out yet.

Xmair

Thanks, Marked as solved and locked.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD