Handle dimension error in tablib

This commit is contained in:
Oliver Walters 2019-07-10 13:04:47 +10:00
parent 482a5dae4b
commit 322710d603
2 changed files with 2 additions and 1 deletions

View File

@ -95,6 +95,8 @@ class BomUploadManager:
self.data = tablib.Dataset().load(raw_data)
except tablib.UnsupportedFormat:
raise ValidationError({'bom_file': _('Error reading BOM file (invalid data)')})
except tablib.core.InvalidDimensions:
raise ValidationError({'bom_file': _('Error reading BOM file (incorrect row size)')})
def guess_header(self, header, threshold=80):
""" Try to match a header (from the file) to a list of known headers

View File

@ -782,7 +782,6 @@ class BomUpload(FormView):
self.extractDataFromFile(manager)
else:
form = self.form
form.errors['bom_file'] = [_('no errors')]
return self.render_to_response(self.get_context_data(form=form))