Get it off your chest – be the first to comment on this video!
No text or picture Add-ons were added yet. How sad!
What I would like you now to do is to open up HsRPC_wt3 and the first thing I would like you to do is to run this application and what you should get is you should get an error when this application is actually run. We should get an actual fault error, well actually we will get an unhandled runtime error and what we are going to learn how to do is actually handle errors much better. So we can see we get this ugly runtime error that says XML parser failure, unterminated elements and again all users would see this. Well, we can actually handle this much better using the default event of the HTTPService class.
So if we scroll down here and find our HTTPService tag, again same code as we have been working with it before, it's just accessing the different XML, the one that has an unterminated elements and then I am just going to specify my fault event and I am just going to say fault and this event is fired anytime, any type of error occurs. So it allows us to handle these errors much better. So here I am going to say fault and then I am going to put in my ActionScript and I am just going to call a function called faultHandler and I am going to pass it at the event object, fault is an event just like resolve or click, so I am going to pass it the event object and then I am going to go back up to the script block up here and I am going to create a new private function and I am going to call that faultHandler and then I am going to type the event object here, and again since I didn’t import the fault event at the top of my class, I am going to have to specify the whole half so I am going to say events:mx.rpc.events.faultEvents and then this particular method won't be returning anything so I am going to specify void and then let’s actually take a look at the event object again.
So go to the last line of the function here and toggle a breakpoint, I am just going to choose Toggle Breakpoint and then what I want you to do is to click File>Save and that will compile it. You should see that there is no problems and then go ahead and debug the application, by clicking on Debugging. You will see that the debugging perspective will automatically launch when it hits that breakpoint, I will click Yes and then you can see the event object that's generated as a result of that fault event and we can see all of the information in that fault event, see for example, there has been XML parser failure. You could see that it could not decode the XML and again that's very useful that we can see all of that information and we can easily display any errors or any problems using that fault event, so a very powerful solution.
Transcription by:
Scribe4you Transcription Services