nagasurendra commited on
Commit
25aa075
·
verified ·
1 Parent(s): 757c081

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -137,10 +137,17 @@ def generate_custom_dish():
137
  }
138
 
139
  # Update the existing Cart_Item__c record in Salesforce
140
- cart_update_result = sf.Cart_Item__c.update(existing_cart_item['Id'], updated_cart_item)
 
 
 
 
 
 
 
141
 
142
- if not cart_update_result.get('success'):
143
- return jsonify({"success": False, "error": "Failed to update cart item in Salesforce"}), 500
144
 
145
  else:
146
  # If the cart item does not exist, create a new one
 
137
  }
138
 
139
  # Update the existing Cart_Item__c record in Salesforce
140
+ try:
141
+ cart_update_result = sf.Cart_Item__c.update(existing_cart_item['Id'], updated_cart_item)
142
+
143
+ # Check the result; Salesforce may return different types of responses
144
+ if isinstance(cart_update_result, dict) and cart_update_result.get('success'):
145
+ return jsonify({"success": True, "message": "Cart item updated successfully"}), 200
146
+ else:
147
+ return jsonify({"success": False, "error": "Failed to update cart item in Salesforce"}), 500
148
 
149
+ except Exception as e:
150
+ return jsonify({"success": False, "error": str(e)}), 500
151
 
152
  else:
153
  # If the cart item does not exist, create a new one