Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var SpecificError = Object.create(Error.prototype);
- SpecificError.constructor = function(message) {
- this.name = 'Specific Error';
- this.message = message;
- this.stack = (new Error).stack;
- return this;
- };
- SpecificError.constructor.prototype = SpecificError;
- function SpecificError(message){
- ...
- }
- Error.call(this,message);
- SpecificError.prototype = Object.create(Error.prototype);
- function SpecificError(message, name) {
- var err = Error.call(this, message);
- err.name = this.name = (name || 'SpecificError');
- err.message = this.message = message;
- Object.defineProperty(this, 'stack', {
- get: function() {
- return err.stack;
- }
- });
- }
Add Comment
Please, Sign In to add comment