Skip to content

Instantly share code, notes, and snippets.

@aredridel
Created January 11, 2011 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aredridel/774092 to your computer and use it in GitHub Desktop.
Save aredridel/774092 to your computer and use it in GitHub Desktop.
Exception inheritance from jsdom
core.DOMException = function(code, message) {
this._code = code;
Error.call(this, core.exceptionMessages[code]);
this.message = core.exceptionMessages[code];
if(message) this.message = this.message + ": " + message;
if(Error.captureStackTrace) Error.captureStackTrace(this, core.DOMException);
};
core.DOMException.prototype = {
get code() { return this._code;},
INDEX_SIZE_ERR : INDEX_SIZE_ERR,
DOMSTRING_SIZE_ERR : DOMSTRING_SIZE_ERR,
HIERARCHY_REQUEST_ERR : HIERARCHY_REQUEST_ERR,
WRONG_DOCUMENT_ERR : WRONG_DOCUMENT_ERR,
INVALID_CHARACTER_ERR : INVALID_CHARACTER_ERR,
NO_DATA_ALLOWED_ERR : NO_DATA_ALLOWED_ERR,
NO_MODIFICATION_ALLOWED_ERR : NO_MODIFICATION_ALLOWED_ERR,
NOT_FOUND_ERR : NOT_FOUND_ERR,
NOT_SUPPORTED_ERR : NOT_SUPPORTED_ERR,
INUSE_ATTRIBUTE_ERR : INUSE_ATTRIBUTE_ERR
};
core.DOMException.prototype.__proto__ = Error.prototype;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment