When I do: ``` js import serializeJavascript from 'serialize-javascript'; const serialized = serializeJavascript({ error: new Error('message') }); console.log(serialized); ``` I'm receiving: ``` js "{\"error\":{}}" ``` Is it intentional or is it a bug?
Activity
[-]Error objects are serialized to `{}`[/-][+]`Error` objects are serialized to `{}`[/+]SidStraw commentedon Dec 11, 2021
I have reviewed the code, and currently, only deal with the following types:
ErrorObject was not handled.If you feel the need, you can try to add it, and I will also try it too.
okuryu commentedon Dec 13, 2021
patches welcome!
wujekbogdan commentedon Dec 13, 2021
I guess it happens because
Errorobject properties are not enumerable. There's a libserialize-errorthat solves this issue.Add support for Error object (yahoo#135)
SidStraw commentedon Dec 16, 2021
Hello, @okuryu @wujekbogdan
I have added a patch about the support
Errorobject. #136PTAL, thx.