Re: [whatwg/dom] Encourage use of AbortError for cancellation? (#927)

> Basically it's up to userland to create a `class AbortError extends Error { code = 'ABORT_ERR' }`.

This is different to browsers, `abortError.code` is just a number in `DOMException`. Currently I've been using `.name === "AbortError"`, however this is somewhat fragile against userland classes as they might forget to add `name = "AbortError";` into the class.

This is one reason I think it'd strongly be best if there was a global exposed in both Node and Browsers that could construct a "blessed" `AbortError` so that people can reliably both construct them and check if a given error is an `AbortError` without relying on userland to correctly implement many copies of `AbortError`. (Or something like the alternative I described above where `abortController.abort()` constructs one).

-- 
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/dom/issues/927#issuecomment-774575239

Received on Sunday, 7 February 2021 01:55:30 UTC