impatient-js
impatient-js copied to clipboard
Chapter: Async functions
Hi. There's a mistake on this page: https://exploringjs.com/impatient-js/ch_async-functions.html#await-and-rejected-promises
try {
await new Error();
assert.fail(); // actuallly we do get here
} catch (e) {
assert.equal(e instanceof Error, true); // and we never get here
}
I'm here for the same reason as @fab1o. In my tests, await new Error()
does not throw. It simply returns the error instance, like any other non-promise value.
@fab1o @anthemion-org: Fixed now. Thanks for reporting this!
@rauschma Hi
Non-Promise values are allowed, too, and simply passed on (synchronously, without pausing the async function)
Maybe I misunderstand sentence, but non-promise values is wrapping according https://tc39.es/ecma262/multipage/ecmascript-data-types-and-values.html#await.
PS. Thx for book