line = next(self._fileo)
except StopIteration:
raise core_ex.NoDataError('Uploaded file contains no data')
+ except UnicodeError as ex:
+ raise core_ex.CantDecodeError(
+ 'Not a text file',
+ ("The file's content is not recognized as Unicode text, "
+ f'the error is: {ex}'))
else:
self.lineno += 1
# Intuit the eol sequence
super(NoDataError, self).__init__(e, descr, detail)
+class CantDecodeError(Error):
+ '''Can't decode file data into unicode'''
+ def __init__(self, e, descr='', detail=''):
+ super().__init__(e, descr, detail)
+
+
class DuplicateUploadError(Error):
'''The same filename updated twice into the same db'''
def __init__(self, e, descr='', detail=''):