Created
April 11, 2016 12:47
-
-
Save leegee/a8444f92f83323365fa082db0f6d3830 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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