Skip to content

Commit

Permalink
Merge pull request #2194 from IFRCGo/feature/fix-sentry-issue-2005
Browse files Browse the repository at this point in the history
Fix ValueError issue for Country key
  • Loading branch information
szabozoltan69 authored Jul 3, 2024
2 parents 1d43e98 + d2b3b22 commit b0f3beb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions api/drf_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,11 @@ def get_object(self):
# NOTE: kwargs is accepting pk for now
# TODO: Can kwargs be other than pk??
pk = self.kwargs["pk"]
country = get_object_or_404(Country, pk=int(pk))
return self.get_queryset().filter(id=country.id).first()
try:
country = get_object_or_404(Country, pk=int(pk))
return self.get_queryset().filter(id=country.id).first()
except ValueError:
raise Exception("An error occured", "Country key is unusable", pk)

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

0 comments on commit b0f3beb

Please sign in to comment.