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