Skip to content

Commit

Permalink
Update to use class comparison instead of string comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasha Dresden committed Mar 6, 2024
1 parent d4f10e6 commit 03eb3b4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions django-backend/fecfiler/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from rest_framework.exceptions import ValidationError
from django.http import HttpResponseServerError
from fecfiler.authentication.views import delete_user_logged_in_cookies
from rest_framework.views import exception_handler
Expand Down Expand Up @@ -25,8 +26,8 @@ def custom_exception_handler(exc, context):
# Do not allow an error response body unless validation
data = getattr(response, 'data')
exception_type = type(exc)
logger.error("Error: {}".format(data))
if data and "ValidationError" not in str(exception_type):
logger.error(f"Error: {data}")
if data and exception_type is not ValidationError:
response.data = None

return response

0 comments on commit 03eb3b4

Please sign in to comment.