fixing error handling for json parsing

This commit is contained in:
Lucas Oskorep
2022-06-23 01:15:31 -04:00
parent 32df9bd9d3
commit befc5f9f81
3 changed files with 13 additions and 8 deletions
+10 -6
View File
@@ -13,9 +13,13 @@ class Event(object):
@staticmethod
def get_from_gcal_api_json(json):
print(json['start'].get('dateTime'))
return Event(
json['summary'] if 'summary' in json else "No Title",
parse(json['start'].get('dateTime')),
parse(json['end'].get('dateTime'))
)
try:
print(json['start'].get('dateTime'))
return Event(
json['summary'] if 'summary' in json else "No Title",
parse(json['start'].get('dateTime')),
parse(json['end'].get('dateTime'))
)
except Exception as e:
print(e)
return None