Skip to content

Commit

Permalink
update article create/update status code
Browse files Browse the repository at this point in the history
  • Loading branch information
happychuks committed Nov 29, 2024
1 parent 8813648 commit 8fda06e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/apps/research/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def create(self, request, *args, **kwargs):
return Response(serializer.data, status=status.HTTP_201_CREATED)
except Exception as e:
logger.error(f"Unexpected error during article creation: {e}")
if isinstance(e, serializers.ValidationError):
return Response({'error': str(e)}, status=status.HTTP_400_BAD_REQUEST)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.
return Response({'error': 'Failed to create a new Article'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)

def update(self, request, *args, **kwargs):
Expand All @@ -53,8 +55,10 @@ def update(self, request, *args, **kwargs):
serializer.is_valid(raise_exception=True)
self.perform_update(serializer)
return Response(serializer.data, status=status.HTTP_200_OK)
except Exception as e:
except Exception as e:
logger.error(f"Unexpected error during article update: {e}")
if isinstance(e, serializers.ValidationError):
return Response({'error': str(e)}, status=status.HTTP_400_BAD_REQUEST)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.
return Response({'error': 'Error updating article'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)

# Custom action to retrieve articles by slug or UUID
Expand Down

0 comments on commit 8fda06e

Please sign in to comment.