Make import errors prettier and actually handle them

This commit is contained in:
Julia Friesel
2018-08-07 18:52:30 +02:00
parent 44cc448209
commit 77bda6bf53
2 changed files with 15 additions and 18 deletions
+4 -10
View File
@@ -37,15 +37,9 @@ export default async function importCsv(csv, deleteFirst) {
}, {})
}
let cycleDays
try {
cycleDays = await csvParser(config)
.fromString(csv)
.on('header', validateHeaders)
} catch(err) {
// TODO
console.log(err)
}
const cycleDays = await csvParser(config)
.fromString(csv)
.on('header', validateHeaders)
//remove symptoms where all fields are null
putNullForEmptySymptoms(cycleDays)
@@ -72,7 +66,7 @@ function tryToCreateCycleDay(day, i) {
try {
db.create('CycleDay', day)
} catch (err) {
const msg = `Error for line ${i + 1}(${day.date}): ${err.message}`
const msg = `Line ${i + 1}(${day.date}): ${err.message}`
throw new Error(msg)
}
}