There comes a time while developing, especially when developing for other developers, that you think “I should really anticipate this error”. This Quick Tip will show you how to do it — the clean way.
Step 1: Throwing
Often, you’ll try to anticipate a bug but end up just tracing something out. Whilst debugging you would find it really useful to throw an exception to make your code stop from executing further, or give some more information about why the error is happening. To do that you need to throw an error to the user, meaning Flash’s debug player will be able to catch it, as will the console when exporting directly from Flash Professional.
Let’s say I’m building a User class; it’s a static class with parameters like name
and gender
.
Now let’s say I want to catch if the user inputs something other than M or F in his/her gender [...]
No comments:
Post a Comment