File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 1010import traceback
1111
1212from rest_framework .exceptions import ValidationError , ErrorDetail , APIException
13+ from rest_framework .utils .serializer_helpers import ReturnDict
1314from rest_framework .views import exception_handler
1415
1516from common import result
@@ -71,7 +72,10 @@ def find_err_detail(exc_detail):
7172 if isinstance (_value , ErrorDetail ):
7273 return f"{ _label } :{ find_err_detail (_value )} "
7374 if isinstance (_value , dict ) and len (_value .keys ()) > 0 :
74- return find_err_detail (_value )
75+ try :
76+ return find_err_detail (ReturnDict (_value , serializer = exc_detail .serializer .fields [key ]))
77+ except Exception as e :
78+ return _value
7579 if isinstance (exc_detail , list ):
7680 for v in exc_detail :
7781 r = find_err_detail (v )
You can’t perform that action at this time.
0 commit comments