Permalink
Browse files

Add stack traces (at least in V8) and messages to DOMExceptions

  • Loading branch information...
aredridel committed Aug 26, 2010
1 parent e9f3ff6 commit 20e006f995fbc86cb3a48487fcbecf73f1d0b60b
Showing with 15 additions and 0 deletions.
  1. +15 −0 lib/jsdom/level1/core.js
View
@@ -50,6 +50,9 @@ var sys = require("sys");
core.DOMException = function(code) {
this._code = code;
+ Error.call(this, messages[code]);
+ this.message = messages[code];
+ if(Error.captureStackTrace) Error.captureStackTrace(this, core.DOMException);
};
core.DOMException.prototype = {
@@ -70,6 +73,18 @@ var NOT_FOUND_ERR = core.NOT_FOUND_ERR = 8;
var NOT_SUPPORTED_ERR = core.NOT_SUPPORTED_ERR = 9;
var INUSE_ATTRIBUTE_ERR = core.INUSE_ATTRIBUTE_ERR = 10;
+var messages = {}
+messages[INDEX_SIZE_ERR] = "Index size error";
+messages[DOMSTRING_SIZE_ERR] = "DOMString size error";
+messages[HIERARCHY_REQUEST_ERR] = "Heirarchy request error";
+messages[WRONG_DOCUMENT_ERR] = "Wrong document";
+messages[INVALID_CHARACTER_ERR] = "Invalid character";
+messages[NO_DATA_ALLOWED_ERR] = "No data allowed";
+messages[NO_MODIFICATION_ALLOWED_ERR] = "No modification allowed";
+messages[NOT_FOUND_ERR] = "Not found";
+messages[NOT_SUPPORTED_ERR] = "Not supported";
+messages[INUSE_ATTRIBUTE_ERR] = "Attribute in use";
+
core.NodeList = function(document, element, tagName) {
this._document = document;
this._element = element;

0 comments on commit 20e006f

Please sign in to comment.