From 8226ab408039b96f262926f36af534bcf3746f1c Mon Sep 17 00:00:00 2001 From: Flavio Fernandes Date: Wed, 30 Dec 2020 17:28:43 -0500 Subject: [PATCH] get_local_time is expected to raise RuntimeError when it fails When response.status_code != 200 from the REST api to TIME_SERVICE the code raises ValueError, which is not what all the examples in Adafruit_Learning_System_Guides handle gracefully. Instead, this situation should be raising the RuntimeError exception. Fixes https://github.com/adafruit/Adafruit_CircuitPython_PyPortal/issues/96 . --- adafruit_pyportal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index bc02891..33a656d 100755 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -722,7 +722,7 @@ def get_local_time(self, location=None): try: response = requests.get(api_url, timeout=10) if response.status_code != 200: - raise ValueError(response.text) + raise RuntimeError(response.text) if self._debug: print("Time request: ", api_url) print("Time reply: ", response.text)