Last active
August 29, 2015 14:17
-
-
Save jordaaash/b7734833cef043a8a3a8 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
'use strict'; | |
class CustomError extends Error { | |
constructor () { | |
super(); | |
var error = Error.apply(null, arguments); | |
Object.getOwnPropertyNames(error).forEach((function(property) { | |
Object.defineProperty(this, property, Object.getOwnPropertyDescriptor(error, property)); | |
}).bind(this)); | |
this.name = this.constructor.name; | |
} | |
} | |
class ApplicationError extends CustomError { | |
contructor (message, something) { | |
super(message); | |
this.something = something; | |
} | |
} |
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
'use strict'; | |
class DelegateError extends Error { | |
constructor () { | |
super(); | |
this._error = Error.apply(null, arguments); | |
} | |
get name () { | |
return this.constructor.name; | |
} | |
get message () { | |
return this._error.message; | |
} | |
get stack () { | |
return this._error.stack; | |
} | |
get fileName () { | |
return this._error.fileName; | |
} | |
get lineNumber () { | |
return this._error.lineNumber; | |
} | |
get columnNumber () { | |
return this._error.columnNumber; | |
} | |
toSource () { | |
return this._error.toSource(); | |
} | |
toString () { | |
return this._error.toString(); | |
} | |
} | |
module.exports = CustomError; | |
class ApplicationError extends DelegateError { | |
contructor (message, something) { | |
super(message); | |
this.something = something; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment