In my Node Express JS web app, I have the following function chain where the subsequent api function tries to call the service function and catch the error thrown from the service function.
In FWBDataExtracService.js
const FWBDataExtracService = {
    getFWBData: async () => {
        ... ...
        // Check if .tabledata exists; If not, throw an error to be caught in the calling function.
        if ($('.tabledata1').length == 0) {
            console.error("DOM element .tabledata not found on the page.");
            throw new Error("DOM element .tabledata not found on the page.");
        }
        ... ...
    }
}
In api.js, the router function is trying to call the FWBDataExtracService.getFWBData function and then catching the error.
const FWBDataExtracService = require('../services/FWBDataExtracService')
router.get('/GetDataFromFWB', async (req, res, next) => {
    try {
        .... ....
        // ### THIS WILL FAIL AND AN ERROR WILL BE THROWN
        const FWBJson = await FWBDataExtracService.getFWBData();
        .... ....
    } catch(err) {
        // ### ERR IS ALWAYS EMPTY
        console.log("*", JSON.stringify(err));
        return res.send({'Error': JSON.stringify(err)});
    }
})
As the error was mimicked I was expecting the error to be caught and print out the err message. But err was always empty.
 
    