Try-Catch blocks are an absolute necessity as without them, you are
putting the operation of your software into the hands of user input
errors, http errors, unintended consequences as well as the myriad of
things that exist outside the "Happy Path". As functions/methods only
give you one return object, it is common practice to throw custom
errors/exceptions as they are a great mechanism for handling dynamic
environments.

 

To answer your second question about a try-catch without statements in
the catch block. If this method is nested inside of another try-catch
block, then an exception here will be swallowed and not be caught in the
calling objects try-catch.

 

KFB

 

From: [email protected] [mailto:[email protected]] On
Behalf Of SJF
Sent: Tuesday, March 03, 2009 6:54 PM
To: flexcoders
Subject: [flexcoders] try, catch, finally ...

 

Technically, it's good practice/professional to use try-catch-finally
blocks in your actionscript logic. This ensures a robust, easily
debugg-able application.

However, can anyone comment if they actually use try-catch-finally or
whether anyone is for or against it's use.

I ask because I've received an application (which streams vidoe) that
was blowing out numerous users CPUs to 100%. Upon further investigation,
it appears that a netstream event is firing 20 times a second, and
within the listener (listener function that is) for the event, there is
a try-catch-finally block. I removed the try-catch-finally and CPU usage
halved on my machine.

Anyone care to comment for or against try-catch-finally and it's use.

 

Steve.




-- 
This message has been scanned for viruses and 
dangerous content by MailScanner <http://www.mailscanner.info/> , and is

believed to be clean. 

<<image003.jpg>>

<<image004.jpg>>

Reply via email to