Skip to content

Commit e39b7f1

Browse files
seer-by-sentry[bot]mhieta
authored andcommitted
fix: handle 410 Gone statuses in API calls
Handle 410 Gone status as ObjectDoesNotExistError in API calls. Refs: PT-1989
1 parent 847d45c commit e39b7f1

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

occurrences/event_api_services.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ def fetch_place_as_json(place_id: str, **filter_params):
3434
if result.status_code == 404:
3535
raise ObjectDoesNotExistError("Could not find the place from the API.")
3636

37+
if result.status_code == 410:
38+
raise ObjectDoesNotExistError(
39+
"The place is no longer available in the API (gone)."
40+
)
41+
3742
result.raise_for_status()
3843

3944
place_obj = json.loads(result.text)
@@ -54,6 +59,11 @@ def fetch_event_as_json(linked_event_id: str, **filter_params):
5459
if result.status_code == 404:
5560
raise ObjectDoesNotExistError("Could not find the event from the API.")
5661

62+
if result.status_code == 410:
63+
raise ObjectDoesNotExistError(
64+
"The event is no longer available in the API (gone)."
65+
)
66+
5767
result.raise_for_status()
5868

5969
event_obj = json.loads(result.text)
@@ -75,6 +85,11 @@ def update_event_to_linkedevents_api(linked_event_id: str, event_obj) -> None:
7585
if result.status_code == 404:
7686
raise ObjectDoesNotExistError("Could not find the event from the API.")
7787

88+
if result.status_code == 410:
89+
raise ObjectDoesNotExistError(
90+
"The event is no longer available in the API (gone)."
91+
)
92+
7893
result.raise_for_status()
7994

8095

@@ -193,6 +208,11 @@ def resolve_unit_name_with_unit_id(study_group: "StudyGroup"):
193208
if result.status_code == 404:
194209
raise ObjectDoesNotExistError("Could not find the place from the API.")
195210

211+
if result.status_code == 410:
212+
raise ObjectDoesNotExistError(
213+
"The place is no longer available in the API (gone)."
214+
)
215+
196216
result.raise_for_status()
197217

198218
unit = json2obj(format_response(result))

0 commit comments

Comments
 (0)