From 09dc2a3eb4d341254535e4d1ab38ff4e213227db Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sun, 9 Aug 2015 23:40:44 +0300 Subject: [PATCH] Make validation error more verbose --- rigForms/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rigForms/models.py b/rigForms/models.py index 775d13b2..ac814016 100644 --- a/rigForms/models.py +++ b/rigForms/models.py @@ -81,13 +81,13 @@ class Form(models.Model, RevisionMixin): try: schemaValue = json.loads(self.schema.schema) - jsonschema.validate(jsonData,schemaValue) #This will raise ValidationError if data doesn't match schema + jsonschema.validate(jsonData,schemaValue) #This will raise jsonschema.ValidationError if data doesn't match schema except ObjectDoesNotExist: pass #halfway through creation this can cause issues except ValueError: raise ValidationError('Invalid JSON in schema, cannot validate') - except jsonschema.ValidationError: #raise a django exception - raise ValidationError('Data is not valid, cannot save') + except jsonschema.ValidationError as e: #raise a django exception + raise ValidationError('Data is not valid, cannot save: '+e.message) def save(self, *args, **kwargs):