Mailspring/packages/nylas-core/extendable-error.js
2016-06-27 10:27:38 -07:00

19 lines
387 B
JavaScript

class ExtendableError extends Error {
constructor(message) {
super(message);
this.name = this.constructor.name;
this.message = message;
Error.captureStackTrace(this, this.constructor);
}
toJSON() {
const obj = {}
Object.getOwnPropertyNames(this).forEach((key) => {
obj[key] = this[key];
});
return obj
}
}
module.exports = ExtendableError