Check the following code, why the error cannot be caught by promise
var promise = new Promise(function(resolve, reject) {
resolve("ok");
setTimeout(function() { throw new Error('test') }, 0)
});
promise.then(function(value) { console.log(value) }).catch(error=>console.log("got an error"));
It won't display got an error. However, if I directly use Throw new Error('test'), it will be caught. Can someone please explain why?