flex FaultEvent捕获java异常
public void updateDataInfo(DataInfo dataInfo) throws DataException {
try {
DataInfo data = (DataInfo) dataDao.getEnityById(poiInfo.getDataId(), DataInfo.class);
if(data .getDataStateId() > 3 && dataInfo.getDataStateId() > 3){
throw new DataException(DataErrorCodes.Data_DOUBLE_AUTHORISE);
}
else{
data.setAuthenticatet(poiInfo.getAuthenticateResult());
data.setCode(poiInfo.getCityCode());
data.setCreateTime(poiInfo.getCreateTime());
data.setEnabled(poiInfo.isEnabled());
data.setDataAddress(poiInfo.getShopAddress());
data.setDataDesc(poiInfo.getShopDesc());
DataStateInfo stateInfo = new DataStateInfo();
stateInfo.setStateId(poiInfo.getDataStateId());
DataTypeInfo type = new DataTypeInfo();
type.setTypeId(poiInfo.getDataTypeId());
data.setDataState(stateInfo);
data.setDataType(type);
DataDao.update(data);
}
}
catch (DaoException e) {
logger.error(e.getErrorCode());
throw new TaxiException(DataErrorCodes.UPDATE_DataINFO_ERROR);
}
}
ublic class DataException extends RuntimeException {
private String errorCode;
public DataException(String errorCode){
this.errorCode = errorCode;
}
/**
* @return the errorCode
*/
public String getErrorCode() {
return errorCode;
}
/**
* @param errorCode the errorCode to set
*/
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
}
public class DataErrorCodes {
public static final String UPDATE_DataINFO_ERROR = "UPDATE_DATAINFO_ERRORS";
}
前台flex用FaultEvent中event.fault.rootCause.errorCode.toString()
private function OnFaultUpdateInfo(event:FaultEvent):void
{
if (event.fault.rootCause.errorCode.toString() == "SHOP_DOUBLE_AUTHORISE")
{
this.dispatchEvent(new ShopEvent(ShopEvent.UPDATESHOPPOIINFOFALUT));
}
else
{
this.dispatchEvent(new ShopEvent(ShopEvent.SHOPCONFALUT));
return;
}
}