all groups > macromedia flash flash remoting > march 2006 >
You're in the

macromedia flash flash remoting

group:

Flash Remoting error handling


Flash Remoting error handling Alex_bs
3/20/2006 1:38:28 PM
macromedia flash flash remoting: :o
HI there,

Does anybody know how to handle a connection error in Flash Remoting (NOT
service error but gateway ) ?

I could not find example codes or help documentation, so I apreciate
any help.

Take a look at the code below(Flash 8 / AS.2.0):


//==============================================================================
================

import mx.services.Log;
import mx.remoting.Service;
import mx.remoting.DataGlue;
import mx.remoting.PendingCall;
import mx.remoting.RecordSet;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;

class Connect_ap{

function Connect_ap(){
// let?s say the link is wrong:
var link_server= "http://localhost/sites/amf/gatewwway.php";
var service="Begin";
var cone = new Service(link_server,null,service);

}

}



// After testing I noticed that If the link is wrong , the service
fault-handling function returns nothing in this case;

//==============================================================================
================

function list(){

var pcs:PendingCall = cone.list();
pcs.responder = new RelayResponder(this,"list_Result","list_Fault");
}

// * HERE *:fault-handling works only for services, not for connection errors:

function list_Fault(fault:FaultEvent){
trace("Service error:...")
trace(fault.fault.faultstring);
}


//==============================================================================
================

So, How do I handle this kind of error in an aplication ?


Thanks for any help !

Re: Flash Remoting error handling Trensic
3/20/2006 8:38:53 PM
I get an error on both if I change the gateway or the method so hopefully this
helps...


import mx.remoting.Service;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
import mx.remoting.PendingCall;
import mx.remoting.RecordSet;
import mx.remoting.DataGlue;
import mx.controls.Alert;

mx.remoting.debug.NetDebug.initialize();

//
--------------------------------------------------------------------------------
// START ALERT WINDOW
//
--------------------------------------------------------------------------------
// Define alert window
function AlertWindow() {
Alert.show(alert_ErrorMessage, alert_ErrorType, Alert.OK, this, null,
"stockIcon", null);
delete alert_ErrorMessage;
delete alert_ErrorType;
}
//
--------------------------------------------------------------------------------
// END ALERT WINDOW
//
--------------------------------------------------------------------------------
//
//
--------------------------------------------------------------------------------
// START COMPONENT FUNCTIONS
//
--------------------------------------------------------------------------------
// ***** START GroupsTypes Connection
// Defined connection to component
function getGroupType() {
var GroupsTypes_sr:Service = new Service("http://yogi/flashservices/gateway",
new Log(Log.Debug), "Revity40.Logic.Documents.DM_getGroupType", null, null);
var GroupsTypes_pc:PendingCall = GroupsTypes_sr.getGroupType();
GroupsTypes_pc.responder = new RelayResponder(this, "getGroupType_Result",
"getGroupType_Fault");
}
// handle a successfull conn
function getGroupType_Result(re:ResultEvent) {
//trace(re.result);
GroupType_tree.dataProvider = re.result;
GroupType_tree.vScrollPolicy = "on";
GroupType_tree.hScrollPolicy = "on";
GroupType_tree.maxHPosition = 400;
GroupType_tree.addEventListener("change", getGroupType_Change);
}
// handle a non-successfull conn
function getGroupType_Fault(fault:FaultEvent):Void {
//trace("fault error");
alert_ErrorMessage = "We could not connect to the data connector (Method:
DM_getGroupType)"+" System Message: "+fault.fault.faultstring;
alert_ErrorType = "System Error";
AlertWindow();
}
// run the function
getGroupType();


AddThis Social Bookmark Button