-
-
Save santigimeno/3939941 to your computer and use it in GitHub Desktop.
Properties of Error instances in the latest V8 included by [email protected] are not enumerable. And thus cannot be serialized through JSON.stringify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> var err = new Error('wtf?'); | |
> JSON.stringify(err) | |
'{"stack":"Error: wtf?\\n at [object Context]:1:11\\n at Interface.<anonymous> (repl.js:179:22)\\n at Interface.emit (events.js:64:17)\\n at Interface._onLine (readline.js:153:10)\\n at Interface._line (readline.js:408:8)\\n at Interface._ttyWrite (readline.js:585:14)\\n at ReadStream.<anonymous> (readline.js:73:12)\\n at ReadStream.emit (events.js:81:20)\\n at ReadStream._emitKey (tty_posix.js:307:10)\\n at ReadStream.onData (tty_posix.js:70:12)","message":"wtf?"}' | |
> Object.keys(err); | |
[ 'stack', 'arguments', 'type', 'message' ] | |
> Object.getOwnPropertyDescriptor(err, 'stack'); | |
{ get: [Function], set: [Function], enumerable: true, configurable: true } | |
> process.versions.v8 | |
'3.1.8.26' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ node | |
> var err = new Error('wtf?'); | |
undefined | |
> JSON.stringify(err); | |
'{}' | |
> Object.keys(err); | |
[ ] | |
> Object.getOwnPropertyDescriptor(err, 'stack'); | |
{ get: [Function], set: [Function], enumerable: false, configurable: true } | |
> console.dir('wtffff fuuuuuuu'); | |
'wtffff fuuuuuuu' | |
> process.versions.v8 | |
'3.6.6.14' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment