You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parsing this should yield an Error instance with these properties restored.
const{ name, message, stack }=JSON.parse(string);// or something saferconsterror=newError(message);Object.defineProperty(error,'name',{value: name});Object.defineProperty(error,'stack',{value: stack});
This doesn't yield the original CustomError class instance, but I suppose it's better to not attempt to restore that since it may have other custom properties or methods which we won't be able to restore anyway.
Describe the bug
Stringifying an Error instance will yield
"{}"
.Steps to reproduce the behavior
https://codesandbox.io/s/delicate-fire-dto12?file=/src/index.js
Expected behavior
A stringified Error should look like:
Parsing this should yield an Error instance with these properties restored.
This doesn't yield the original CustomError class instance, but I suppose it's better to not attempt to restore that since it may have other custom properties or methods which we won't be able to restore anyway.
Workaround
However this doesn't yield an Error instance, just a plain object.
The text was updated successfully, but these errors were encountered: