From dbb72495fe00971c977030f52489552b17ca8e62 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Wed, 22 Jan 2025 17:46:15 +0000 Subject: [PATCH] If JSON fails to parse show the body of the response. --- check.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/check.py b/check.py index 787763e..eb78380 100755 --- a/check.py +++ b/check.py @@ -7,6 +7,7 @@ import smtplib import sys import requests +import simplejson.errors MAIL_FROM = "edward@4angle.com" MAIL_TO = "edward@4angle.com" @@ -35,7 +36,11 @@ def send_mail(subject: str, body: str) -> None: def check_for_paris_events() -> None: """Check for upcoming OSM events in Paris and send an email if found.""" r = requests.get(URL) - events = r.json() + try: + events = r.json() + except simplejson.errors.JSONDecodeError: + print(r.text) + raise paris_events = [ event for event in events if "paris" in event["location"]["detailed"].lower()