API error Handling
This commit is contained in:
parent
22cfc18bb8
commit
c53484e8a4
@ -1139,16 +1139,13 @@ def updatePrices():
|
||||
prices = {}
|
||||
|
||||
# USD -> INR
|
||||
response = requests.get(
|
||||
f"https://api.exchangeratesapi.io/latest?base=USD&symbols=INR")
|
||||
response = requests.get(f"https://api.exchangerate-api.com/v4/latest/usd")
|
||||
try:
|
||||
price = response.json()
|
||||
if price['success'] == False:
|
||||
raise ValueError('API response error')
|
||||
prices['USDINR'] = price['rates']['INR']
|
||||
except ValueError:
|
||||
response = requests.get(
|
||||
f"https://api.exchangerate-api.com/v4/latest/usd")
|
||||
f"https://api.exchangeratesapi.io/latest?base=USD&symbols=INR")
|
||||
try:
|
||||
price = response.json()
|
||||
prices['USDINR'] = price['rates']['INR']
|
||||
|
||||
Loading…
Reference in New Issue
Block a user