DOMException and PromiseRejectionEvent are globals and follow the
WebIDL and
HTML standards, including legacy
DOMException codes and constants such as DOMException.ABORT_ERR.
Example
// misc.mjs
const error = new DOMException("upload took too long", "TimeoutError");
console.log(error.name, error.code === DOMException.TIMEOUT_ERR, error instanceof Error);
globalThis.addEventListener("unhandledrejection", (event) => {
event.preventDefault();
console.log("unhandled:", event.reason.message);
});
Promise.reject(new Error("lost"));elide run misc.mjs prints:
TimeoutError true true
unhandled: lostElide dispatches unhandledrejection on globalThis when a Promise rejects without a handler, and
rejectionhandled when a handler is attached later. onunhandledrejection and onrejectionhandled also work.
Reference
Status: Full · Not measured
Exports
| Export | Kind | Status | Notes |
|---|---|---|---|
DOMException | class | Full | name, message, code, INDEX_SIZE_ERR, DOMSTRING_SIZE_ERR, HIERARCHY_REQUEST_ERR, WRONG_DOCUMENT_ERR, INVALID_CHARACTER_ERR, NO_DATA_ALLOWED_ERR, NO_, NOT_FOUND_ERR, NOT_SUPPORTED_ERR, INUSE_ATTRIBUTE_ERR, INVALID_STATE_ERR, SYNTAX_ERR, INVALID_, NAMESPACE_ERR, INVALID_ACCESS_ERR, VALIDATION_ERR, TYPE_MISMATCH_ERR, SECURITY_ERR, NETWORK_ERR, ABORT_ERR, URL_MISMATCH_ERR, QUOTA_EXCEEDED_ERR, TIMEOUT_ERR, INVALID_NODE_TYPE_ERR, DATA_CLONE_ERR |
PromiseRejectionEvent | class | Full | promise, reason |