Skip to content

Commit

Permalink
improved error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskoenig committed Nov 1, 2019
1 parent 884fd7f commit a86b796
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions backend/pkdb_app/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,9 @@ def to_internal_related_fields(self, data):

except (ObjectDoesNotExist, MultipleObjectsReturned) as err:
if err == ObjectDoesNotExist:
msg = f'group: {data.get("group")} in study: {study_sid} does not exist'
msg = f'group <{data.get("group")}> does not exist, check groups.'
else:
msg = f'group: {data.get("group")} in study: {study_sid} has been defined multiple times.'
msg = f'group <{data.get("group")}> is defined multiple times.'

raise serializers.ValidationError(msg)

Expand All @@ -568,10 +568,10 @@ def to_internal_related_fields(self, data):
).pk

except ObjectDoesNotExist:
msg = f'individual: individual <{data.get("individual")}> in study: <{study_sid}> does not exist'
msg = f'individual: individual <{data.get("individual")}> does not exist, check individuals.'
raise serializers.ValidationError(msg)
except MultipleObjectsReturned:
msg = f'individual: Multiple individuals with the name <{data.get("individual")}> have been declared on study.'
msg = f'individual: individual <{data.get("individual")}> is defined multiple times'
raise serializers.ValidationError(msg)

if "interventions" in data:
Expand All @@ -590,7 +590,7 @@ def to_internal_related_fields(self, data):
).pk
)
except ObjectDoesNotExist:
msg = f"intervention: <{intervention}> in study: <{study_sid}> does not exist"
msg = f"intervention <{intervention}> does not exist, check interventions."
raise serializers.ValidationError(msg)
data["interventions"] = interventions
return data
Expand Down

0 comments on commit a86b796

Please sign in to comment.