Добавил обработку исключений

This commit is contained in:
quaduzi 2023-06-30 14:25:32 +07:00
parent e71dc22d51
commit fea29956d2
1 changed files with 8 additions and 7 deletions

View File

@ -193,15 +193,16 @@ def get_slot_by_id(
slot_id: str, slot_id: str,
service: Resource = Depends(get_calendar_service) service: Resource = Depends(get_calendar_service)
): ):
event_dict = service.events().get( try:
calendarId=CALENDAR_ID, event_dict = service.events().get(
eventId=slot_id calendarId=CALENDAR_ID,
).execute() eventId=slot_id
event = CalendarEvent(**event_dict) ).execute()
except Exception:
if not event:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Slot not found") raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Slot not found")
event = CalendarEvent(**event_dict)
return event return event