Prev | Current Page 369 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

message );
}
}
}
Now, if you compile these, you should get the following print to screen:
ErrorObjectTest.hx:14: Not an instance : Class : ObjectNotInstantiated
- > new()
line 7 : Item is not an instance of an object
To get different results, try throwing an instance of GenericError instead (remembering to pass a
descriptive string). Alternatively, try rearranging the catch statements, so you can see how each error
type is filtered.
All you have really done here is create a bare - bones exception class that any new exception class can
derive. The GenericError class includes a parameter of type haxe.PosInfos in the constructor, so
that, when instantiated, the exception will be able to provide a detailed account of where the exception
was thrown.
Now, because any class extending the GenericError class will essentially be a new type all of its own,
you can specifically target these classes inside a catch statement. Alternatively, specifying the
GenericError class itself will target this and all derivatives of this class, providing a complete error -
trapping framework.


Pages:
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381