- From: Livia Medeiros <notifications@github.com>
- Date: Mon, 25 Jul 2022 01:25:39 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/1090/1193741223@github.com>
From reading through the referred issues, I don't really see any exact arguments against using `cause`. In fact, earlier issues even had non-standard suggestions such as https://github.com/whatwg/dom/issues/951#issuecomment-786250877 with `reason` property. During that time, [error cause proposal](https://github.com/tc39/proposal-error-cause) was at Stage 3 so it's natural that it wasn't used in prior standards. It is also natural to keep consistent behavior between subsystems (hence why it's a `dom` issue, not `fetch`). However, if compatibility is the most important factor, the upcoming changes in Fetch are going to break both backward and forward compatibility anyway. `TimeoutError` and arbitrary errors will appear; and in userland there will be no way to ensure that any future abort reasons will be caught and handled as abort. > If you want to say it's an "AbortError" DOMException and provide additional data, you'd have to annotate that exception object with that data and signal with that. This is somewhat possible if we call `AbortController.abort()`, but not with `AbortSignal.timeout()`. > I've been searching for several hours through issues and don't see a resolution anywhere that's being consistently applied across environments. Node.js seems to have consistently opted for using `cause` ([examples](https://github.com/nodejs/node/search?p=2&q=%22new+AbortError%22)). Apparently there is an issue with Node.js perspective and very similar concerns: https://github.com/whatwg/dom/issues/1033. Node.js has its own `AbortError` which is not a `DOMException`. It allows to have the desired behavior independently, but it's also likely to become a headache with more DOM API parts implemented (most notably atm, undici is spec-compliant). > However, one aspect of the `cause` approach that seems unaddressed is that `DOMException` doesn't seem to specify `cause` yet. I haven't found an issue for that. Should I open one? Yes, good idea. `DOMException` are instances of `Error` and spec [asks](https://webidl.spec.whatwg.org/#es-DOMException-specialness) it to have all features of `Error`s; it would be great if `DOMException()` constructor supported `cause` as well. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/1090#issuecomment-1193741223 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/1090/1193741223@github.com>
Received on Monday, 25 July 2022 08:25:52 UTC