Improve CSV import error handling, closes #324
This commit is contained in:
parent
b406870756
commit
46acece89c
2 changed files with 8 additions and 1 deletions
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<label for="listimport" class="col-sm-2 control-label">{{#translate}}CSV File{{/translate}}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="file" class="form-control" name="listimport" id="listimport" required>
|
||||
<span class="help-block">{{#translate}}The first line must contain column headings{{/translate}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue