diff --git a/memberPlumbing/upcomingEvents.py b/memberPlumbing/upcomingEvents.py
index cd7e4e3..5d6b5f0 100644
--- a/memberPlumbing/upcomingEvents.py
+++ b/memberPlumbing/upcomingEvents.py
@@ -9,30 +9,34 @@ from .config import Config
def format_event(event_details, truncate: bool):
- url = (
- "https://claremontmakerspace.org/events/#!event/register/"
- + event_details["url"]
- )
- if "lgo" in event_details:
- img = (
- f""""""
+ try:
+ url = (
+ "https://claremontmakerspace.org/events/#!event/register/"
+ + event_details["url"]
)
- else:
- img = ""
- # print(json.dumps(event_details))
- out = f"""
+ if "lgo" in event_details:
+ img = f""""""
+ else:
+ img = ""
+ # print(json.dumps(event_details))
+ out = f"""
{event_details['szp']} — {event_details['ezp']}
"""
- if not truncate:
- out += f"""
+ if not truncate:
+ out += f"""
{event_details['dtl']}
Register for this class now!"""
- return out
+ return out
+ except KeyError as e:
+ print(
+ f"Event '{event_details.get('ttl')}' missing required property: '{e.args[0]}'"
+ )
+ raise
def format_section(title: str, blurb: str, events, truncate: bool):
@@ -62,22 +66,28 @@ def generate_post():
full_events = []
upcoming_events = []
for event in events["evt"]:
- # ignore hidden events
- if event["cal"] == 0:
- continue
- event_details = membershipworks.get_event_by_eid(event["eid"])
+ try:
+ # ignore hidden events
+ if event["cal"] == 0:
+ continue
+ event_details = membershipworks.get_event_by_eid(event["eid"])
- # registration has already ended
- if (
- "erd" in event_details
- and datetime.fromtimestamp(event_details["erd"]) < now
- ):
- ongoing_events.append(event_details)
- # class is full
- elif event_details["cnt"] >= event_details["cap"]:
- full_events.append(event_details)
- else:
- upcoming_events.append(event_details)
+ # registration has already ended
+ if (
+ "erd" in event_details
+ and datetime.fromtimestamp(event_details["erd"]) < now
+ ):
+ ongoing_events.append(event_details)
+ # class is full
+ elif event_details["cnt"] >= event_details["cap"]:
+ full_events.append(event_details)
+ else:
+ upcoming_events.append(event_details)
+ except KeyError as e:
+ print(
+ f"Event '{event.get('ttl')}' missing required property: '{e.args[0]}'"
+ )
+ raise
header = """
Greetings Upper Valley Makers: