🐛(back) fix ValidationError exception handler

The exception handler for the ValidationError was not testing correctly
the existence of some attributes like `message_dict`.
This commit is contained in:
Manuel Raynaud
2025-03-06 14:46:46 +01:00
parent 5bb7ad643a
commit 38eb6d45b7
2 changed files with 11 additions and 7 deletions

View File

@@ -17,9 +17,10 @@ def exception_handler(exc, context):
https://gist.github.com/twidi/9d55486c36b6a51bdcb05ce3a763e79f
"""
if isinstance(exc, ValidationError):
detail = exc.message_dict
if hasattr(exc, "message"):
detail = None
if hasattr(exc, "message_dict"):
detail = exc.message_dict
elif hasattr(exc, "message"):
detail = exc.message
elif hasattr(exc, "messages"):
detail = exc.messages