Is there any alternative to Bluebird's Promise.try
function? As I'm using async/await
not interested in adding bluebird dependency.
Is there a better way to capture asynchronous error
in Node.JS
await Promise.try(async function() {
// Some code with async operations like readline
await this.nextCall(batchData, true);
}).catch(async function(err) {
// My error handling
});
Any inbuilt functions in Node.js 10.x ?
UPDATE :
Is there a better way to capture asynchronous error
in Node.JS
try {
let interfaceVal = lineReader.createInterface({
input: fs.createReadStream(filePath)
});
interfaceVal.on('line', async (line) => {
throw new Error('My custom Error');
});
// some sync operations
} catch(e) {
// This catch won't get called with custom error
console.log(e);
}
Any idea to capture such asynchronous errors?