Skip to content

Instantly share code, notes, and snippets.

@jordaaash
Last active August 29, 2015 14:17
Show Gist options
  • Save jordaaash/b7734833cef043a8a3a8 to your computer and use it in GitHub Desktop.
Save jordaaash/b7734833cef043a8a3a8 to your computer and use it in GitHub Desktop.
'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;
}
}
'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