From 5de616ff893b92823d207723d3154a176eaa5c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Lindahl=20Fl=C3=A5ten?= Date: Fri, 31 Jul 2020 15:26:49 +0200 Subject: [PATCH] [modules/contrib/stock] handle urllib request exception Handle exception that is raised when e.g. your network connection is down. --- bumblebee_status/modules/contrib/stock.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bumblebee_status/modules/contrib/stock.py b/bumblebee_status/modules/contrib/stock.py index c8bfb5e..36afe17 100644 --- a/bumblebee_status/modules/contrib/stock.py +++ b/bumblebee_status/modules/contrib/stock.py @@ -56,7 +56,11 @@ class Module(core.module.Module): self.__symbols + "&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: logging.error("unable to retrieve stock exchange rate") return None