View comments | RSS feed

Using events to handle errors

Just as you can use events to connect application functionality, you can also use them to handle errors. Flex data services contain a fault event that is triggered when a data service has a problem returning result data. You can write an ActionScript event handler function that responds to fault events. The following example shows how you specify a fault event handler for a web service operation:

<mx:Script>
   <![CDATA[
      function showErrorDialog(error){
         // Function implementation...
      }
   ]]>
</mx:Script>
...
<mx:WebService id="WeatherService" ...">
       <mx:operation name="getFoo" fault="showErrorDialog(event.faultString);"/>
</mx:WebService>

Version 1.5

Comments


chazter said on Jul 21, 2005 at 2:54 AM :
Hey,

I think there is syntax error with the line:

fault="showErrorDialog(event.faultString)

I think it should be:

fault="showErrorDialog(event.fault.faultstring)

When I used the example given above with a RemoteObject type, the flex compiler complained that the property faultstring didn't exist. So I looked through the other flex docs and noticed that a composite object was used within the event called "fault".

All works now though! Hope this is right and helps :o)
jrunrandy said on Jul 26, 2005 at 8:58 AM :
You are correct. I have entered doc bug 134935 to track this issue.

Randy Nielsen
Flex IMD Manager

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/15/flex_docs_en/00000066.htm