Socket
Socket
Sign inDemoInstall

domexception

Package Overview
Dependencies
1
Maintainers
6
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

domexception

An implementation of the DOMException class from browsers

    4.0.0latest
    GitHub
    npm

Version published
Maintainers
6
Weekly downloads
19,289,498
increased by4.65%

Weekly downloads

Package description

What is domexception?

The domexception npm package provides a way to create DOMException objects, which represent exceptions that occur while interacting with the Document Object Model (DOM). This package is particularly useful when working with DOM-like structures in non-browser environments, such as Node.js, where the DOMException global is not available by default.

What are domexception's main functionalities?

Creating a new DOMException

This feature allows you to create a new DOMException object with a custom error message and name. The name should be one of the DOMException error names, such as 'NotFoundError', 'SyntaxError', etc.

const DOMException = require('domexception');
const exception = new DOMException('Error message', 'NotFoundError');

Checking the instance of DOMException

This feature is useful for checking if a given object is an instance of DOMException, which can be helpful for error handling and debugging.

const exception = new DOMException('Error message', 'NotFoundError');
console.log(exception instanceof DOMException); // true

Other packages similar to domexception

Readme

Source

DOMException

This package implements the DOMException class, from web browsers. It exists in service of jsdom and related packages.

Example usage:

const DOMException = require("domexception");

const e1 = new DOMException("Something went wrong", "BadThingsError");
console.assert(e1.name === "BadThingsError");
console.assert(e1.code === 0);

const e2 = new DOMException("Another exciting error message", "NoModificationAllowedError");
console.assert(e2.name === "NoModificationAllowedError");
console.assert(e2.code === 7);

console.assert(DOMException.INUSE_ATTRIBUTE_ERR === 10);

APIs

This package exposes two flavors of the DOMException interface depending on the imported module.

domexception module

This module default-exports the DOMException interface constructor.

domexception/webidl2js-wrapper module

This module exports the DOMException interface wrapper API generated by webidl2js.

Keywords

FAQs

Last updated on 06 Oct 2021

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc