I'm having trouble with some asynchronous functions in a nodejs server. This is the first time that I deal with try/catch blocks and I cannot catch the error inside the called function.
my code:
calledFunction: async function() {
try{
//DO SOMETHING THAT RETURNS AN ERROR
}
catch(error) {
//NEED TO CATCH THIS ERROR IN mainFunction()
var error = {};
error.error = err.message;
return error;
}
}
mainFunction: async function () {
try {
await this.calledFunction();
return true;
}
catch(error) {
var error = {};
error.error = err.message;
return error
}
}