Can we improve async JavaScript error handling?

Lars Eidnes larseidnes at gmail.com
Mon Dec 2 17:10:30 UTC 2019


> But since setTimeout() is not part of ECMAScript proper, this is not the
proper place to discuss it. See rather:

Thanks Claude for this pointer. The callback-free implementation proposed
at the end of that thread seems like it would fix the issues I'm thinking
of, without requiring anything new from the language/runtime. Cool.

On Mon, Dec 2, 2019 at 10:15 AM Claude Pache <claude.pache at gmail.com> wrote:

>
>
> 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
>
>
>
> 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/8fdaf891/attachment.html>


More information about the es-discuss mailing list