Improve CSV import error handling, closes #324

This commit is contained in:
witzig 2017-09-29 00:31:38 +02:00
parent b406870756
commit 46acece89c
2 changed files with 8 additions and 1 deletions

View file

@ -636,8 +636,14 @@ function getPreview(path, size, delimiter, callback) {
fs.close(fd, () => {
// just ignore
});
if (err) {
return callback(err);
}
if (!data || !data.length) {
return callback(null, new Error(_('Empty file')));
return callback(new Error(_('Empty file')));
}
if (data.length < 2) {
return callback(new Error(_('Too few rows')));
}
callback(err, data);
});