Skip to main content

DOMException

Less than 1 minutefeatureweb-standard

DOMException

The specification.open in new window

Modules

Types

class DOMException {
  constructor(message: string, name?: string);
  readonly name: string;
  readonly message: string;
  readonly code: string;
  stack: string; // in engines that should have it
  [Symbol.toStringTag]: "DOMException";
}

Entry points

core-js(-pure)/stable|actual|full/dom-exception
core-js(-pure)/stable|actual|full/dom-exception/constructor
core-js/stable|actual|full/dom-exception/to-string-tag

Example

Exampleopen in new window:

const exception = new DOMException("error", "DataCloneError");
console.log(exception.name); // => 'DataCloneError'
console.log(exception.message); // => 'error'
console.log(exception.code); // => 25
console.log(typeof exception.stack); // => 'string'
console.log(exception instanceof DOMException); // => true
console.log(exception instanceof Error); // => true
console.log(exception.toString()); // => 'DataCloneError: error'
console.log(Object.prototype.toString.call(exception)); // => '[object DOMException]'