Skip to content

Commit

Permalink
Fix bug in update mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
dglemos committed Nov 6, 2024
1 parent f871e42 commit feffa2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ def update_mechanism(self, lgd_instance, validated_data):
primary_type = evidence_type.get("primary_type", None)
if not primary_type:
raise serializers.ValidationError({"message": f"Empty evidence subtype"})
primary_type = primary_type.lower()
primary_type = primary_type.replace(" ", "_").lower()
# secondary_type is the evidence value ('human')
secondary_type = evidence_type.get("secondary_type")
for m_type in secondary_type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,16 @@ def patch(self, request, stable_id):
try:
serializer.update_mechanism(lgd_obj, mechanism_data)
except Exception as e:
return Response(
{"error": f"Error while updating molecular mechanism"},
if hasattr(e, 'detail') and 'message' in e.detail:
return Response(
{"error": f"Error while updating molecular mechanism: {e.detail['message']}"},
status=status.HTTP_500_INTERNAL_SERVER_ERROR
)
else:
return Response(
{"error": f"Error while updating molecular mechanism"},
status=status.HTTP_500_INTERNAL_SERVER_ERROR
)
else:
return Response(
{"message": f"Molecular mechanism updated successfully for '{stable_id}'"},
Expand Down

0 comments on commit feffa2a

Please sign in to comment.