[modules/contrib/stock] handle urllib request exception

Handle exception that is raised when e.g. your network connection is
down.
This commit is contained in:
Andreas Lindahl Flåten 2020-07-31 15:26:49 +02:00
parent 72d255f0ae
commit 5de616ff89

View file

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