DOMException-impl.js 571 B

12345678910111213141516171819202122
  1. "use strict";
  2. const legacyErrorCodes = require("./legacy-error-codes.json");
  3. const idlUtils = require("./utils.js");
  4. exports.implementation = class DOMExceptionImpl {
  5. constructor([message, name]) {
  6. this.name = name;
  7. this.message = message;
  8. }
  9. get code() {
  10. return legacyErrorCodes[this.name] || 0;
  11. }
  12. };
  13. // A proprietary V8 extension that causes the stack property to appear.
  14. exports.init = impl => {
  15. if (Error.captureStackTrace) {
  16. const wrapper = idlUtils.wrapperForImpl(impl);
  17. Error.captureStackTrace(wrapper, wrapper.constructor);
  18. }
  19. };