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
Just playing with some code and discovered that JSON.stringify called against Error instances are empty objects which seems weird since message and stack are string properties? And since errors are usually of interest.
console.log(JSON.stringify(newError('foo')));// {}classFooextendsError{constructor(){super(...arguments);}toJSON(){return{message: this.message,stack: this.stack}}}console.log(JSON.stringify(newFoo('foo')));// now we have some output
maybe the Error class should come with a toJSON implementation?
The text was updated successfully, but these errors were encountered:
Yeah I figured the fact that they were non-enumerable properties was it. Tell the V8 people I guess, seems weird that you wouldnt want to see error stack/messages in serialized data, although good for security in some cases.
You can close this one - people can extend Error if they really want to serialize them or what not.
Just playing with some code and discovered that JSON.stringify called against Error instances are empty objects which seems weird since message and stack are string properties? And since errors are usually of interest.
maybe the Error class should come with a toJSON implementation?
The text was updated successfully, but these errors were encountered: