In the following code
// file: main.js
class A {
async start() {
throw 'error';
}
}
module.exports = A;
// file index.js
var r = require('./main.js');
let v = new r();
try {
v.start(); // error is caught when I use r.start() though
} catch (e) {
console.error(e);
}
I am new to Javascript and Node.js, Node.js throws UnhandledPromiseRejection when I am clearly catching the exception, why does it happen ?