new Promise(async (resolve, reject) =>
{
try
{
await new Promise((resolveSec, rejectSec) =>
{
setTimeout(function()
{
resolveSec('')
}, 1000);
}).then(function(val)
{
return reject('should reject') //does not stop execution
//throw('should reject'); //stops execution
});
console.log('not here'); //should not get to here
}
catch (err)
{
console.log('caught error');
}
}).catch(function(err)
{
console.log(err);
});
Could someone explain why the above code does not end execution on "reject" but it works with "throw" as I thought that both "reject" and "throw" inside Promise have same functionality.