Prev | Current Page 381 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


196
Part I: The Core Language
The only real benefit to using the - debug flag with regard to exception handling is that of the
callStack and exceptionStack functions. Supposedly, the flash.Lib.setErrorHandler()
function also requires the - debug flag set, though you have not seen any benefits in doing so.
public function getStack() : String
{
var es = haxe.Stack.exceptionStack();
var str : String = StringTools.rpad( ???StackTrace\n???, ???=???, 21 ) + ???\n???;
str += haxe.Stack.toString( es );
return str;
}
public function getCallStack() : String
{
var cs = haxe.Stack.callStack();
var str : String = StringTools.rpad( ???CallStackTrace\n???, ???=???, 26 ) + ???\n???;
str += haxe.Stack.toString( cs );
return str;
}
These two functions will provide function call and exception stack information when required, but will
return undefined when the - debug flag is not provided. As - debug is a compiler flag, however, you can
make use of compiler directives and choose to return a polite string should the exceptionStack() and
callStack() functions be unavailable.


Pages:
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393