ITADN

vm: node.js v0.12: Mangled exceptions generated in the evalmachine

#25904Closedn-riesco 创建于 2015-08-28
N
n-riescocommented
Both Node.js v.010 and the latest io.js don't mangle the exceptions generated in the evalmachine. See this example: ``` > var e; try { vm.runInThisContext("throw new Error()") } catch (ee) { e = ee }; [Error] > e.name 'Error' > e.message '' > e.stack 'Error\n at evalmachine.<anonymous>:1:7\n at repl:1:17\n at REPLServer.self.eval (repl.js:110:21)\n at repl.js:249:20\n at REPLServer.self.eval (repl.js:122:7)\n at Interface.<anonymous> (repl.js:239:12)\n at Interface.EventEmitter.emit (events.js:95:17)\n at Interface._onLine (readline.js:202:10)\n at Interface._line (readline.js:531:8)\n at Interface._ttyWrite (readline.js:760:14)' ``` whereas Node.js v0.12 does: ``` > var e; try { vm.runInThisContext("throw new Error()") } catch (ee) { e = ee }; { [Error: evalmachine.<anonymous>:1 throw new Error() ^ ] message: 'evalmachine.<anonymous>:1\nthrow new Error()\n ^\n' } > e.name 'Error' > e.message 'evalmachine.<anonymous>:1\nthrow new Error()\n ^\n' > e.stack 'evalmachine.<anonymous>:1\nthrow new Error()\n ^\nError\n at evalmachine.<anonymous>:1:7\n at Object.exports.runInThisContext (vm.js:74:17)\n at repl:1:17\n at REPLServer.defaultEval (repl.js:132:27)\n at bound (domain.js:254:14)\n at REPLServer.runBound [as eval] (domain.js:267:12)\n at REPLServer.<anonymous> (repl.js:279:12)\n at REPLServer.emit (events.js:107:17)\n at REPLServer.Interface._onLine (readline.js:214:10)\n at REPLServer.Interface._line (readline.js:553:8)' ``` Note that this change breaks software depending on the output of `e.message` and `e.stack`.
关闭于 2023-04-22 1 条评论