Skip to content

iexitdev/dom-exception-modern

dom-exception-modern

Native DOMException migration helpers for JavaScript and TypeScript.

domexception is deprecated because modern runtimes expose DOMException directly. This package default-exports the native constructor for migration compatibility and adds small typed helpers for converting and checking errors.

Install

npm install dom-exception-modern

Usage

import DOMException, { createDOMException, isDOMException } from "dom-exception-modern";

const error = new DOMException("Cannot modify this value", "NoModificationAllowedError");

if (isDOMException(error)) {
  console.log(error.code);
}

createDOMException("Aborted", "AbortError");

API

default export / DOMException

The runtime's native DOMException constructor.

createDOMException(message?, name?)

Creates a native DOMException.

isDOMException(value)

Checks whether a value behaves like a DOMException.

toDOMException(value, name?)

Converts unknown thrown values to DOMException.

domExceptionCodes

Named legacy constants from the native constructor.

Migration Position

dom-exception-modern is an independent alternative or migration helper for projects moving away from domexception. It is not affiliated with the original package maintainers or project.

For release context, see the local migration guide, examples, compatibility notes, source metadata, and adoption plan.

About

Native DOMException migration helpers and domexception-compatible default export.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors