Prev | Current Page 364 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


Compile this class now for both the Flash and Neko virtual machines. If successful, your Neko output
should now present just the one line of text; the specific error found in the main function. However, the
Flash player still doesn ??™ t output anything. As discussed earlier, exceptions are part of an object
framework oriented at dealing with errors and unexpected events, so it would seem that the Flash player
does not deal with these by default.
So, how do you deal with exceptions in a virtual machine that doesn ??™ t seem to throw any? The answer is
to throw your own.
188
Part I: The Core Language
Throwing Exceptions
To throw an exception means to create an exception object and launch it into the exception handling
framework. Now, this might sound like playing catch with oneself, which it indubitably is, but if that
ball returns to you every time with some useful information, then it ??™ s a game worth playing.
In order to throw an exception, you need to know when to throw it and how. Now, understanding how
to throw an exception is easy.


Pages:
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376