summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alarmpy/alarmpy.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/alarmpy/alarmpy.py b/alarmpy/alarmpy.py
index c43ff6c..1d090b3 100644
--- a/alarmpy/alarmpy.py
+++ b/alarmpy/alarmpy.py
@@ -114,11 +114,14 @@ class Alarm:
def fetch(self):
try:
res = self.session.get(self.URL, headers=self.HEADERS, timeout=1)
- if not res.ok and "Access Denied" in res.text:
- self.output_error(
- "API endpoint has denied access. This might be due to geolocation limitations, please try running from an Israeli-based IP or proxy."
- )
- exit(1)
+ if not res.ok:
+ if "Access Denied" in res.text:
+ self.output_error(
+ "API endpoint has denied access. This might be due to geolocation limitations, please try running from an Israeli-based IP or proxy."
+ )
+ exit(1)
+ else:
+ raise Exception("HTTP request has failed") from e
return res.content
except requests.Timeout as e:
raise Exception("HTTP request timed out") from e