If you
think about it, though, returning a negative integer from a function is not exactly a descriptive way of
alerting a developer to errors. For instance, it may be fine to assume that a negative value denotes an
error while a positive number denotes success, but where, then, does zero fit into this? Should you
consider it an error, or a successful return value? The fact is, it could mean either, depending on the rules
of the functions you ??™ re calling.
Another issue you should consider is, what happens if there are several ways that a function can cause
an error? Do you return different negative values depending on that error? Again, this is not a very
descriptive option. This is why exceptions are so valuable, and why you should make use of them in
your own applications.
Dealing with Exceptions
So now you know why you should use exceptions. Unfortunately, while haXe is a language with
exception support, the supported platforms don ??™ t really see eye to eye on how best to implement them.
When Neko was written, Nicolas Cannasse decided that any uncaught exception should be exposed to
the user and the program that generated the exception should end.
Pages:
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372