Mailspring/packages/nylas-core/nylas-error.js
Juan Tejada ed749e0f51 Add sync worker error handling
- Handles sync errors in a single place. For now, if error is not a
socket error, will treat as a permanent error, save the error to the
account object, and prevent any other syncing until the error is cleared
from the account object
- Adds a NylasError class that can be extended and serialized. Adds it
to global namespace on all packages and replaces all uses of regular
Error
2016-06-27 16:03:38 -07:00

19 lines
377 B
JavaScript

class NylasError 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 = NylasError