mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-10 10:11:25 +08:00
19 lines
387 B
JavaScript
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
|