better error handling when there are problems getting shipping estimates

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@604343 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Si Chen
2007-12-15 00:14:16 +00:00
parent 4b4280aa9b
commit fdff481f3b
2 changed files with 15 additions and 8 deletions
@@ -29,6 +29,7 @@ import org.ofbiz.entity.GenericValue;
import org.ofbiz.order.shoppingcart.ShoppingCart;
import org.ofbiz.product.store.ProductStoreWorker;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.service.ServiceUtil;
public class ShippingEstimateWrapper {
@@ -94,8 +95,10 @@ public class ShippingEstimateWrapper {
shippingMethodTypeId, carrierPartyId, carrierRoleTypeId, shippingCmId, productStoreId,
shippableItemInfo, shippableWeight, shippableQuantity, shippableTotal);
Double shippingTotal = (Double) estimateMap.get("shippingTotal");
shippingEstimates.put(shipMethod, shippingTotal);
if (!ServiceUtil.isError(estimateMap)) {
Double shippingTotal = (Double) estimateMap.get("shippingTotal");
shippingEstimates.put(shipMethod, shippingTotal);
}
}
}
}
@@ -181,7 +181,7 @@ public class ShippingEvents {
shippingTotal += externalAmt.doubleValue();
}
} catch (GeneralException e) {
return ServiceUtil.returnSuccess(standardMessage);
return ServiceUtil.returnError(standardMessage);
}
// update the initial amount
@@ -194,7 +194,7 @@ public class ShippingEvents {
shippingTotal += genericAmt.doubleValue();
}
} catch (GeneralException e) {
return ServiceUtil.returnSuccess(standardMessage);
return ServiceUtil.returnError(standardMessage);
}
// return the totals
@@ -213,7 +213,7 @@ public class ShippingEvents {
Debug.logError(e, "Shipment Service Error", module);
throw new GeneralException();
}
if (ServiceUtil.isError(genericEstimate)) {
if (ServiceUtil.isError(genericEstimate) || ServiceUtil.isFailure(genericEstimate)) {
Debug.logError(ServiceUtil.getErrorMessage(genericEstimate), module);
throw new GeneralException();
} else if (ServiceUtil.isFailure(genericEstimate)) {
@@ -256,12 +256,16 @@ public class ShippingEvents {
Debug.logError(e, "Shipment Service Error", module);
throw new GeneralException(e);
}
if (!ServiceUtil.isError(serviceResp)) {
externalShipAmt = (Double) serviceResp.get("shippingEstimateAmount");
} else {
if (ServiceUtil.isError(serviceResp)) {
String errMsg = "Error getting external shipment cost estimate: " + ServiceUtil.getErrorMessage(serviceResp);
Debug.logError(errMsg, module);
throw new GeneralException(errMsg);
} else if (ServiceUtil.isFailure(serviceResp)) {
String errMsg = "Failure getting external shipment cost estimate: " + ServiceUtil.getErrorMessage(serviceResp);
Debug.logError(errMsg, module);
throw new GeneralException(errMsg);
} else {
externalShipAmt = (Double) serviceResp.get("shippingEstimateAmount");
}
}
}