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

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,
service: Resource = Depends(get_calendar_service)
):
try:
event_dict = service.events().get(
calendarId=CALENDAR_ID,
eventId=slot_id
).execute()
event = CalendarEvent(**event_dict)
if not event:
except Exception:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Slot not found")
event = CalendarEvent(**event_dict)
return event