Merge pull request #687 from anlif/main
[modules/contrib/stock] handle urllib request exception
This commit is contained in:
commit
f8d035c079
1 changed files with 5 additions and 1 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue