You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.1 KiB

  1. # DOMException
  2. This package implements the [`DOMException`](https://heycam.github.io/webidl/#idl-DOMException) class, from web browsers. It exists in service of [jsdom](https://github.com/tmpvar/jsdom) and related packages.
  3. Example usage:
  4. ```js
  5. const DOMException = require("domexception");
  6. const e1 = new DOMException("Something went wrong", "BadThingsError");
  7. console.assert(e1.name === "BadThingsError");
  8. console.assert(e1.code === 0);
  9. const e2 = new DOMException("Another exciting error message", "NoModificationAllowedError");
  10. console.assert(e2.name === "NoModificationAllowedError");
  11. console.assert(e2.code === 7);
  12. console.assert(DOMException.INUSE_ATTRIBUTE_ERR === 10);
  13. ```
  14. ## APIs
  15. This package exposes two flavors of the `DOMException` interface depending on the imported module.
  16. ### `domexception` module
  17. This module default-exports the `DOMException` interface constructor.
  18. ### `domexception/webidl2js-wrapper` module
  19. This module exports the `DOMException` [interface wrapper API](https://github.com/jsdom/webidl2js#for-interfaces) generated by [webidl2js](https://github.com/jsdom/webidl2js).