Добавил обработку исключений
This commit is contained in:
parent
e71dc22d51
commit
fea29956d2
15
src/main.py
15
src/main.py
|
@ -193,15 +193,16 @@ def get_slot_by_id(
|
|||
slot_id: str,
|
||||
service: Resource = Depends(get_calendar_service)
|
||||
):
|
||||
event_dict = service.events().get(
|
||||
calendarId=CALENDAR_ID,
|
||||
eventId=slot_id
|
||||
).execute()
|
||||
event = CalendarEvent(**event_dict)
|
||||
|
||||
if not event:
|
||||
try:
|
||||
event_dict = service.events().get(
|
||||
calendarId=CALENDAR_ID,
|
||||
eventId=slot_id
|
||||
).execute()
|
||||
except Exception:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Slot not found")
|
||||
|
||||
event = CalendarEvent(**event_dict)
|
||||
|
||||
return event
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue