impatient-js icon indicating copy to clipboard operation
impatient-js copied to clipboard

Chapter: Async functions

Open rauschma opened this issue 6 years ago • 5 comments

rauschma avatar Jul 19 '18 04:07 rauschma

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
}

fab1o avatar Sep 25 '19 07:09 fab1o

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.

anthemion-org avatar Nov 15 '19 04:11 anthemion-org

@fab1o @anthemion-org: Fixed now. Thanks for reporting this!

rauschma avatar Jan 02 '22 12:01 rauschma

@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

effrenus avatar Feb 13 '22 10:02 effrenus