Closed dackmin closed 5 years ago
So:
Agreed that .stack and .name should be preserved as-is. Please feel free to make a PR which fixes this and I'll gladly merge and publish.
.code
is non-standard but seems to be a strong convention in the javascript world. Even NodeJS uses it by default: https://nodejs.org/api/errors.html#errors_error_code -- but yeah agreed it probably should not be used for passing a data object. I'm open to including .data
if you'd like to PR that in too.
All in all -- good suggestions. Thanks for the issue!
This is fixed in the latest version.
Is there any particular reason
.stack
and.name
Error properties are not serialized as-is ? Currently.stack
is prefixed with.message
and.name
is simply replaced with the defaultError
one.Also, I currently have to use your non-standard
.code
property to pass error data (typically an object — for an xhr error for example) between child/parents. Would it be possible to add a new.data
or.whatever
property to the error serializer ? This would be particularly useful when extending Error using ES6 classes.