Mailspring/packages/nylas-core/extendable-error.js

19 lines
387 B
JavaScript
Raw Normal View History

2016-06-28 01:27:38 +08:00
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