[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:
parent
72d255f0ae
commit
5de616ff89
1 changed files with 5 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue