Skip to content

Commit b0f3beb

Browse files
Merge pull request #2194 from IFRCGo/feature/fix-sentry-issue-2005
Fix ValueError issue for Country key
2 parents 1d43e98 + d2b3b22 commit b0f3beb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

api/drf_views.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,11 @@ def get_object(self):
223223
# NOTE: kwargs is accepting pk for now
224224
# TODO: Can kwargs be other than pk??
225225
pk = self.kwargs["pk"]
226-
country = get_object_or_404(Country, pk=int(pk))
227-
return self.get_queryset().filter(id=country.id).first()
226+
try:
227+
country = get_object_or_404(Country, pk=int(pk))
228+
return self.get_queryset().filter(id=country.id).first()
229+
except ValueError:
230+
raise Exception("An error occured", "Country key is unusable", pk)
228231

229232
def get_serializer_class(self):
230233
if self.request.GET.get("mini", "false").lower() == "true":

0 commit comments

Comments
 (0)