Guest User

Untitled

a guest
Nov 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. var SpecificError = Object.create(Error.prototype);
  2. SpecificError.constructor = function(message) {
  3. this.name = 'Specific Error';
  4. this.message = message;
  5. this.stack = (new Error).stack;
  6. return this;
  7. };
  8. SpecificError.constructor.prototype = SpecificError;
  9.  
  10. function SpecificError(message){
  11. ...
  12. }
  13.  
  14. Error.call(this,message);
  15.  
  16. SpecificError.prototype = Object.create(Error.prototype);
  17.  
  18. function SpecificError(message, name) {
  19. var err = Error.call(this, message);
  20. err.name = this.name = (name || 'SpecificError');
  21. err.message = this.message = message;
  22. Object.defineProperty(this, 'stack', {
  23. get: function() {
  24. return err.stack;
  25. }
  26. });
  27. }
Add Comment
Please, Sign In to add comment