Skip to content
Browse files

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

Conflicts:

	lib/jsdom/level1/core.js
  • Loading branch information...
1 parent 53f5763 commit 6cebfa67e892665e58a5fac62d8a2d9d962dae9f @aredridel aredridel committed Aug 26, 2010
Showing with 16 additions and 3 deletions.
  1. +16 −3 lib/jsdom/level1/core.js
View
19 lib/jsdom/level1/core.js
@@ -48,14 +48,15 @@ var core = {
};
var sys = require("sys");
-core.DOMException = function(code, msg) {
+core.DOMException = function(code) {
this._code = code;
- this._msg = msg || ""
+ Error.call(this, messages[code]);
+ this.message = messages[code];
+ if(Error.captureStackTrace) Error.captureStackTrace(this, core.DOMException);
};
core.DOMException.prototype = {
get code() { return this._code;},
- get msg() { return thise._msg; }
};
core.DOMException.prototype.__proto__ = Error.prototype;
@@ -72,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 6cebfa6

Please sign in to comment.
Something went wrong with that request. Please try again.