Skip to content

Commit

Permalink
Add stack traces (at least in V8) and messages to DOMExceptions
Browse files Browse the repository at this point in the history
Conflicts:

	lib/jsdom/level1/core.js
  • Loading branch information
aredridel committed Aug 26, 2010
1 parent 53f5763 commit 6cebfa6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/jsdom/level1/core.js
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 6cebfa6

Please sign in to comment.