Fix AttributeError

Exceptions aren't guaranteed to have a 'message' attribute. It does have
'args', but str(ex) is probably more useful as it's likely to include
the exception type.
This commit is contained in:
Sybren A. Stüvel 2017-10-17 11:32:03 +02:00
parent 9c3667b51f
commit 72f440f509

View File

@ -181,7 +181,7 @@ class JSONRequired(validators.DataRequired):
try:
json.loads(field.data)
except ValueError as ex:
message = self.message or ex.message
message = self.message or str(ex)
field.errors[:] = []
raise validators.StopValidation(message)