en.javascript.info/1-js/11-async/04-promise-error-handling/01-error-async/solution.md
2019-03-05 18:44:28 +03:00

13 lines
407 B
Markdown

The answer is: **no, it won't**:
```js run
new Promise(function(resolve, reject) {
setTimeout(() => {
throw new Error("Whoops!");
}, 1000);
}).catch(alert);
```
As said in the chapter, there's an "implicit `try..catch`" around the function code. So all synchronous errors are handled.
But here the error is generated not while the executor is running, but later. So the promise can't handle it.