W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2018

Re: throw vs promise reject

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 20 Sep 2018 11:45:25 -0700
Message-ID: <CAAWBYDD6b83=YF5K6-31Jd6QqT39tn30nDcYANess2RD8xF=dA@mail.gmail.com>
To: horus.scope@gmail.com
Cc: public-webapps <public-webapps@w3.org>
On Mon, Sep 17, 2018 at 2:38 PM Guru Partap Khalsa
<horus.scope@gmail.com> wrote:
> What is the reasoning for XMLHttpRequest to "throw" rather than rejecting a promise? It almost seems sarcastic to ask why a stack trace is helpful when the network times out.

Tangential to what Boris just said, note that all promises rejected by
the platform get rejected with an Error, so you still get a stack
trace either way. ^_^

(And this is the generally correct practice, as `await` turns a
rejection into a thrown error.)

Received on Thursday, 20 September 2018 18:46:00 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:15:15 UTC