Can we improve async JavaScript error handling?

Claude Pache claude.pache at gmail.com
Mon Dec 2 09:15:30 UTC 2019



> Le 29 nov. 2019 à 21:05, Lars Eidnes <larseidnes at gmail.com> a écrit :
> 
> 
> 
> 1) Is it a good idea to introduce an alternative to setTimeout, where the distinction is that it returns a Promise, and that return/throw in the callback take the role of resolve/reject?

I think so (although there is no need keep the callback). But since setTimeout() is not part of ECMAScript proper, this is not the proper place to discuss it. See rather:

https://github.com/whatwg/html/issues/617 <https://github.com/whatwg/html/issues/617>


> 
> 2) Are there other things we could do to minimize the need for resolve/reject? 
> 

I don’t think there is anything to do at the core language level, because it has already the necessary tools (async/await). Rather, new APIs ought to be designed in order to be directly usable with `await`, i.e., they ought to return a Promise instead of taking a callback or having an event-handler. F.e., the old XMLHttpRequest API shall be replaced with the new Fetch API.

—Claude
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20191202/a9267ca5/attachment.html>


More information about the es-discuss mailing list