serialise() { const logData = this.data.map((e) => { // JSON.stringify(new Error('test')) returns {}, which is not really useful for us. // The following allows us to serialize errors correctly. if (e && e.message && e.stack) { e = Object.assign({ message: e.message, stack: e.stack }, e); } if(isNaN(e) && typeof e === 'number') { e = 'NaN' } return e; }); this.data = logData; return flatted.stringify(this); }
serialise() { const logData = this.data.map((e) => { // JSON.stringify(new Error('test')) returns {}, which is not really useful for us. // The following allows us to serialize errors correctly. if (e && e.message && e.stack) { e = Object.assign({ message: e.message, stack: e.stack }, e); } if(isNaN(e) && typeof e === 'number') { e = 'NaN' } return e; }); this.data = logData; return flatted.stringify(this); }