1
0
mirror of https://github.com/etesync/server synced 2024-12-29 10:48:07 +00:00

Serializers: cleanup how we handle validation errors.

This commit is contained in:
Tom Hacohen 2020-12-22 13:15:12 +02:00
parent 3fcea20d68
commit 1cb84cfa6d

View File

@ -149,10 +149,8 @@ class BetterErrorsMixin:
ret.extend(self.flatten_errors("{}.{}".format(field_name, error_key), error)) ret.extend(self.flatten_errors("{}.{}".format(field_name, error_key), error))
else: else:
for error in errors: for error in errors:
if hasattr(error, "detail"): if error.messages:
message = error.detail[0] message = error.messages[0]
elif hasattr(error, "message"):
message = error.message
else: else:
message = str(error) message = str(error)
ret.append( ret.append(