跳至主要內容

DOMException

小于 1 分钟featureweb-standard

DOMException

规范open in new window

模块

类型

class DOMException {
  constructor(message: string, name?: string);
  readonly name: string;
  readonly message: string;
  readonly code: string;
  stack: string; // 引擎中应该包含
  [Symbol.toStringTag]: "DOMException";
}

入口点

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

示例

示例open 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]'