Make loaddata error messages less cryptic
|Reported by:||bigfudge||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
At present, error messages when running loaddata don't include any clue about the part of the serialised data which caused the problem.
In the Deserialiser function (in core.serializers.json.py) there is a try/except block on line 40 to 47 which could be amended to aid the user:
def Deserializer(stream_or_string, **options): """ Deserialize a stream or string of JSON data. """ if isinstance(stream_or_string, basestring): stream = StringIO(stream_or_string) else: stream = stream_or_string try: for obj in PythonDeserializer(simplejson.load(stream), **options): yield obj except GeneratorExit: raise except Exception, e: # Map to deserializer error raise DeserializationError(e)
If raise DeserializationError(e) were changed to raise DeserializationError(e, obj) then the function would return a tuple containing the current error message (which isn't that informative) and the object which causes the error.
This has been a big issue for me recently in migrating a pilot installation which used sqlite over to postgres. There were a number of data integrity issues which using postgres highlighted, but it was only by applying this change that it became possible to identify the records which were causing the problem.
Change History (19)
comment:1 Changed 2 years ago by claudep
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:2 Changed 2 years ago by carljm
- Resolution set to needsinfo
- Status changed from new to closed
comment:6 Changed 11 months ago by claudep
- Has patch set
- Needs tests set
- Resolution needsinfo deleted
- Status changed from closed to new