Prev | Current Page 384 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

All you have to do is to concatenate the output of each function into a single
return value, like this:
public function toString() : String
{
var str : String = getMessage() + ???\n??? + getSource();
str += ???\n\n??? + getStack();
str += ???\n\n??? + getCallStack();
return str;
}
You shouldn ??™ t need to worry about whether the - debug flag is set for the getStack() method call, as
the function should already handle this for you.
The Exception Class Code
That completes the Exception class. Later in the book, you revisit this class and add a few extra
features, but for now, here is the class in its entirety:
class Exception
{
private var __description : String;
private var __infos : haxe.PosInfos;
private var __calls : String;
(continued)
198
Part I: The Core Language
public var message(getMessage,null) : String;
public var source(getSource,null) : String;
public var stackTrace(getStack,null) : String;
public var callStack(getCallStack,null) : String;
public function new( msg : String, ?info : haxe.


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