Добавил обработку исключений
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,
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue