Closed
Description
Having to do this is bad code smell
if (!globalThis.DOMException) {
try {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
} catch (err) {
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
Since we are aligning more with Web standard APIs now days with the arise of URL, URLSearchParams, Event & EventTarget, MessageChannel, Workers, BroadcastChannel, Blob, File, AbortController, atob, bota, TextEncoder, TextDecoder etc
It would only start to make sense to expose DOMException globally so you are able to check if a error is a instances of DOMException.
Pollyfills need this Error class also.
And more feature web standard apis is probably going to need it.