If JSON fails to parse show the body of the response.

This commit is contained in:
Edward Betts 2025-01-22 17:46:15 +00:00
parent 01409b7246
commit dbb72495fe

View file

@ -7,6 +7,7 @@ import smtplib
import sys import sys
import requests import requests
import simplejson.errors
MAIL_FROM = "edward@4angle.com" MAIL_FROM = "edward@4angle.com"
MAIL_TO = "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: def check_for_paris_events() -> None:
"""Check for upcoming OSM events in Paris and send an email if found.""" """Check for upcoming OSM events in Paris and send an email if found."""
r = requests.get(URL) r = requests.get(URL)
events = r.json() try:
events = r.json()
except simplejson.errors.JSONDecodeError:
print(r.text)
raise
paris_events = [ paris_events = [
event for event in events if "paris" in event["location"]["detailed"].lower() event for event in events if "paris" in event["location"]["detailed"].lower()