sindresorhus/serialize-error

v7 doesn't work as described

Closed this issue ยท 3 comments

The breaking change in v7 turned the example from the README.md useless:

const {serializeError, deserializeError} = require('serialize-error');

const error = new Error('๐Ÿฆ„');

console.log(error);
//=> [Error: ๐Ÿฆ„]

const serialized = serializeError(error)

console.log(serialized);
//=> {name: 'Error', message: '๐Ÿฆ„', stack: 'Error: ๐Ÿฆ„\n    at Object.<anonymous> โ€ฆ'}

const deserialized = deserializeError(serialized);
//=> [Error: ๐Ÿฆ„]

The serialized error looks just like an empty object now, and is missing the name, message, and stack properties on the console. Actually, for me this was the most useful feature, and hence v7 is a huge step into the wrong direction.

I understand that you wanted to change it this way to keep things consistent โ€“ however, is there a chance to make this configurable?

Technically, we only really need to do this for deserializeError. For serialize, we can make them enumerable.

// @Weakky

That would be awesome โค๏ธ

Ah indeed, sorry for the inconvenience. Will take care of that shortly