Skip to content

Commit

Permalink
Catch exception in related terms method
Browse files Browse the repository at this point in the history
Just return an empty list if there are any errors here.

Sentry error: MEDIATHREAD-PK
  • Loading branch information
nikolas committed Dec 23, 2024
1 parent 1ca6adf commit d981ee2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mediathread/djangosherd/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ class Meta:
list_allowed_methods = []
detail_allowed_methods = []

def render_related_terms(self, bundle):
def render_related_terms(self, bundle) -> list:
termResource = TermResource()
vocabulary = {}
for rel in bundle.obj.termrelationship_set.all():

try:
terms = bundle.obj.termrelationship_set.all()
except ValueError:
return []

for rel in terms:
if rel.term.vocabulary.id not in vocabulary:
vocabulary[rel.term.vocabulary.id] = {
'id': rel.term.vocabulary.id,
Expand Down

0 comments on commit d981ee2

Please sign in to comment.