# Other globals

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

`DOMException` and `PromiseRejectionEvent` are globals and follow the
[WebIDL](https://webidl.spec.whatwg.org/#idl-DOMException) and
[HTML](https://html.spec.whatwg.org/multipage/webappapis.html#promiserejectionevent) standards, including legacy
`DOMException` codes and constants such as `DOMException.ABORT_ERR`.

## Example

```js
// 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:

```text
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.

<!-- api-reference:start 0c0e5bb66439 -->
## 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_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` |
| `PromiseRejectionEvent` | class | Full | `promise`, `reason` |
<!-- api-reference:end -->
