Handle non-csv file error
This commit is contained in:
parent
33fa0b50b7
commit
15d0d178d6
|
@ -130,14 +130,25 @@ module S3Module {
|
|||
})
|
||||
.createReadStream()
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
stream
|
||||
.on("error", (err: Error) => {
|
||||
reject(err)
|
||||
})
|
||||
.on("finish", async () => {
|
||||
resolve(csv().fromStream(stream))
|
||||
let csvError = false
|
||||
return new Promise(async (resolve, reject) => {
|
||||
stream.on("error", (err: Error) => {
|
||||
reject(err)
|
||||
})
|
||||
const response = csv()
|
||||
.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