Saltar al contenido

Esta página aún no está traducida. Se muestra en inglés.

Other globals

How Elide supports the DOMException and PromiseRejectionEvent globals, and the unhandledrejection and rejectionhandled events on globalThis.

En esta página
Open in ChatGPTOpen in Claude

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: lost

Elide 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

ExportKindStatusNotes
DOMExceptionclassFullname, message, code, INDEX_SIZE_ERR, DOMSTRING_SIZE_ERR, HIERARCHY_REQUEST_ERR, WRONG_DOCUMENT_ERR, INVALID_CHARACTER_ERR, NO_DATA_ALLOWED_ERR, NO_MODIFICATION_ALLOWED_ERR, NOT_FOUND_ERR, NOT_SUPPORTED_ERR, INUSE_ATTRIBUTE_ERR, INVALID_STATE_ERR, SYNTAX_ERR, INVALID_MODIFICATION_ERR, 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
PromiseRejectionEventclassFullpromise, reason

¿Te resultó útil esta página?