serialize-javascript
                                
                                 serialize-javascript copied to clipboard
                                
                                    serialize-javascript copied to clipboard
                            
                            
                            
                        `Error` objects are serialized to `{}`
When I do:
import serializeJavascript from 'serialize-javascript';
const serialized = serializeJavascript({  error: new Error('message') });
console.log(serialized);
I'm receiving:
"{\"error\":{}}"
Is it intentional or is it a bug?
I have reviewed the code, and currently, only deal with the following types:
RegExp,
Date,
Map,
Set,
Array,
URL,
function,
undefined,
number,
bigint
Error Object was not handled.
If you feel the need, you can try to add it, and I will also try it too.
patches welcome!
I guess it happens because Error object properties are not enumerable. There's a lib serialize-error that solves this issue.
Hello, @okuryu @wujekbogdan
I have added a patch about the support Error object. #136
PTAL, thx.