Merge pull request #687 from anlif/main

[modules/contrib/stock] handle urllib request exception
This commit is contained in:
tobi-wan-kenobi 2020-08-01 10:36:23 +02:00 committed by GitHub
commit f8d035c079
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -56,7 +56,11 @@ class Module(core.module.Module):
self.__symbols self.__symbols
+ "&fields=regularMarketPrice,currency,regularMarketChange" + "&fields=regularMarketPrice,currency,regularMarketChange"
) )
return urllib.request.urlopen(url).read().strip() try:
return urllib.request.urlopen(url).read().strip()
except urllib.request.URLError:
logging.error("unable to open stock exchange url")
return None
else: else:
logging.error("unable to retrieve stock exchange rate") logging.error("unable to retrieve stock exchange rate")
return None return None