UnhandledPromiseRejection despite catching expection

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 {
    } catch (e) {

I am new to Javascript and Node.js, Node.js throws UnhandledPromiseRejection when I am clearly catching the exception, why does it happen ?

16 thoughts on “UnhandledPromiseRejection despite catching expection”

Leave a Comment