From 22cfc18bb812695839d8f603c250b405a13ecb4e Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Thu, 26 Aug 2021 07:58:11 +0000 Subject: [PATCH] Handling bad API response --- ranchimallflo_api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ranchimallflo_api.py b/ranchimallflo_api.py index 56c306f..3dda4ab 100644 --- a/ranchimallflo_api.py +++ b/ranchimallflo_api.py @@ -1143,6 +1143,8 @@ def updatePrices(): f"https://api.exchangeratesapi.io/latest?base=USD&symbols=INR") try: price = response.json() + if price['success'] == False: + raise ValueError('API response error') prices['USDINR'] = price['rates']['INR'] except ValueError: response = requests.get(