I have been porting all my Future based code on the server to async / await (just using Meteor defaults, no external library, everything works out of the box). However, I have lost all error reporting, even the most basic ones. The execution just silently fails and halts.
Consider this function to parse a CSV
const csv_stream_to_array = stream => new Promise ((resolve, reject) => {
const r = []
stream.on('line', line => r.push(line.split(';').map (s => { const c = +s ; return (c != c) ? s : c })))
stream.on('close', () => resolve(r))
})
const parse_csv_file = filename => {
const char_stream = FS.createReadStream(filename, { encoding :'utf8' })
const line_stream = Readline.createInterface({ input : char_stream, terminal : false })
return csv_stream_to_array (line_stream)
}
const main = async () => {
const result = await parse_csv_file ('some_file.csv')
console.log(result)
}
main()
Any error will make it silently fail, including misnamed variables.
How do I get back proper errors ?