- From: Mattias Buelens <notifications@github.com>
- Date: Tue, 23 Nov 2021 02:59:24 -0800
- To: whatwg/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Tuesday, 23 November 2021 10:59:37 UTC
You're right, it's no longer sufficient to only ignore `AbortError` DOMExceptions. Following the suggestion in https://github.com/whatwg/dom/pull/1027#pullrequestreview-782289936, we would need something along the lines of: ```javascript AbortSignal.prototype.ignoreAborts = function (promise) { promise = Promise.resolve(promise); return promise.catch(e => { if (this.aborted && e === this.reason) { // swallow exception } else { // rethrow throw e; } }); }; ``` which authors could use as: ```javascript async butterBiscuits({ signal }) { try { const result = await signal.ignoreAborts(fetch('https://butternet/the-good-stuff?lots', { signal })); if (result) { this.biscuits.butter = result; } } catch (err) { alerts.push('a TERRIBLE thing happened'); throw err; } } ``` It's kind of weird that you have to use `signal` twice, though. 😕 -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/webidl/issues/933#issuecomment-976401575
Received on Tuesday, 23 November 2021 10:59:37 UTC