node.js - Extra info displayed in uncaught error vs caught Error object -
if run erroneous file node err.js
console.log(hi);   it throws error, if uncaught shows this: (note first 2 lines)
c:\test\err.js:2     console.log(hi);                 ^ referenceerror: hi not defined     @ object.<anonymous> (c:\test\err.js:2:17)     @ module._compile (module.js:426:26)     @ object.module._extensions..js (module.js:444:10)   but if try-catch error , display error object:
try {     console.log(hi); } catch (err) {     console.error(err);     console.error(err.message);     console.error(err.stack); }     [referenceerror: hi not defined] hi not defined referenceerror: hi not defined     @ object.<anonymous> (c:\test\err.js:2:17)     @ module._compile (module.js:426:26)     @ object.module._extensions..js (module.js:444:10)     @ module.load (module.js:351:32)     @ function.module._load (module.js:306:12)     @ function.module.runmain (module.js:467:10)     @ startup (node.js:117:18)     @ node.js:948:3   where part go:
c:\test\err.js:2     console.log(hi);                 ^   how can retrieve piece of info error object?
 
 
  
Comments
Post a Comment