Skip to content

Commit

Permalink
Catch request exceptions for our remote calendar calls. (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn authored Feb 5, 2024
1 parent f9cfe20 commit 7735d9f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions backend/src/appointment/routes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import secrets

import requests.exceptions
import validators
from requests import HTTPError
from sentry_sdk import capture_exception
Expand Down Expand Up @@ -223,7 +224,13 @@ def read_remote_calendars(
)
else:
con = CalDavConnector(connection.url, connection.user, connection.password)
return con.list_calendars()

try:
calendars = con.list_calendars()
except requests.exceptions.RequestException:
raise RemoteCalendarConnectionError()

return calendars


@router.post("/rmt/sync")
Expand Down Expand Up @@ -277,7 +284,12 @@ def read_remote_events(
)
else:
con = CalDavConnector(db_calendar.url, db_calendar.user, db_calendar.password)
events = con.list_events(start, end)

try:
events = con.list_events(start, end)
except requests.exceptions.RequestException:
raise RemoteCalendarConnectionError()

for e in events:
e.calendar_title = db_calendar.title
e.calendar_color = db_calendar.color
Expand Down

0 comments on commit 7735d9f

Please sign in to comment.