Handle non-csv file error
This commit is contained in:
parent
1e70f6afb4
commit
8c40394d35
|
@ -130,14 +130,25 @@ module S3Module {
|
||||||
})
|
})
|
||||||
.createReadStream()
|
.createReadStream()
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
let csvError = false
|
||||||
stream
|
return new Promise(async (resolve, reject) => {
|
||||||
.on("error", (err: Error) => {
|
stream.on("error", (err: Error) => {
|
||||||
reject(err)
|
reject(err)
|
||||||
})
|
})
|
||||||
.on("finish", async () => {
|
const response = csv()
|
||||||
resolve(csv().fromStream(stream))
|
.fromStream(stream)
|
||||||
|
.on("error", () => {
|
||||||
|
csvError = true
|
||||||
})
|
})
|
||||||
|
stream.on("finish", () => {
|
||||||
|
resolve(response)
|
||||||
|
})
|
||||||
|
}).catch(err => {
|
||||||
|
if (csvError) {
|
||||||
|
throw new Error("Could not read CSV")
|
||||||
|
} else {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue