What is the best approach to managing an error, such as the one labeled "new error" in the code snippet below, that occurs outside of a promise?
function testError() {
throw new Error("new error") // How can this error be properly handled?
var p123 = new Promise(function(resolve, reject) {
resolve(123)
});
return p123
};
testError().catch(err => {
return err; // The execution does not reach here
})
.then(ok => {
console.log(ok)
});