From fea29956d2f0fb2c9dcccbfe13eb935b186de16f Mon Sep 17 00:00:00 2001 From: quaduzi Date: Fri, 30 Jun 2023 14:25:32 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D1=83=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main.py b/src/main.py index 92ee4f6..c69ac9f 100644 --- a/src/main.py +++ b/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