Handling bad API response

This commit is contained in:
Vivek Teega 2021-08-26 07:58:11 +00:00
parent aca9064b9b
commit 22cfc18bb8

View File

@ -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(