Skip to content

Commit

Permalink
Fix error handling
Browse files Browse the repository at this point in the history
Returning exception content as Response data discloses stack trace information
  • Loading branch information
nas-tabchiche committed Feb 12, 2024
1 parent c2df8b2 commit 3afda84
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/library/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ def destroy(self, request, *args, pk, **kwargs):
try:
library.delete()
except IntegrityError as e:
return Response(data=str(e), status=status.HTTP_400_BAD_REQUEST)
# TODO: Log the exception if logging is set up
# logging.exception("Integrity error while deleting library: %s", e)
print(e)
except Exception as e:
# TODO: Log the exception if logging is set up
# logging.exception("Unexpected error while deleting library: %s", e)
print(e)
return Response(
data="Unexpected error occurred while deleting the library.",
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
Expand Down

0 comments on commit 3afda84

Please sign in to comment.