Serialize an error into a plain object
Useful if you for example need to JSON.stringify()
or process.send()
the error.
$ npm install serialize-error
const serializeError = require('serialize-error');
const error = new Error('๐ฆ');
console.log(error);
//=> [Error: ๐ฆ]
console.log(serializeError(error));
//=> {name: 'Error', message: '๐ฆ', stack: 'Error: ๐ฆ\n at Object.<anonymous> โฆ'}
MIT ยฉ Sindre Sorhus