Skip to content

Instantly share code, notes, and snippets.

@leegee
Created April 11, 2016 12:47
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 leegee/a8444f92f83323365fa082db0f6d3830 to your computer and use it in GitHub Desktop.
Save leegee/a8444f92f83323365fa082db0f6d3830 to your computer and use it in GitHub Desktop.
Base.prototype.ERROR = [];
Base.errorNames = [
'PageContext', 'NotYetSupported', 'NaN', 'ColDefPropertyNotFound',
'ColDefValueNotFound', 'InvalidArgument', 'MissingArgument',
'UnknownError', 'InvalidCssSelector'
];
Base.errorNames.forEach(function(errName) {
Base.prototype.ERROR[errName] = function (message) {
Error.captureStackTrace(this, this.constructor);
this.message = message;
}
Base.prototype.ERROR[errName].prototype = Object.create(Error.prototype, {
constructor: {
value: errName,
writable: true,
configurable: true,
name: errName
}
});
Base.prototype.ERROR[errName].prototype.name = errName;
Base.prototype.ERROR[errName].prototype.constructor = Base.prototype.ERROR[errName];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment