3

Similar questions has been asked, I went through 'how to debug node' threads, but those are however either old or not about the problem i got.

Problem:

I'm writing some small tools in node.js stack - and my debugging experience is quite frustrating: when an exception is thrown, in many cases I get very annoying messages like the one here:

TypeError: Bad argument

wtf? it's neither verbose or useful - no source line number, no information in which file this exception was thrown.

Question:

How do I get my console to output usefull information when exceptions/errors are thrown and console.log function has something to say. would be great to have a simple console.log call where it actually puts a line number and maybe a file name where the message happens.

Inoperable
  • 1,429
  • 5
  • 17
  • 33
  • I don't know how to track the info you want on console but debugging is very easy with WebStorm IDE. I recommend it. – Snow Blind Jul 27 '13 at 13:21
  • Use one of the debugging approaches from here: http://stackoverflow.com/questions/12641679/nodejs-a-step-by-step-debugger-for-nodejs – JohnnyHK Aug 03 '14 at 13:21

2 Answers2

2

in nodejs i use this function to see error stack:

process.on('uncaughtException', function(err) {
    console.log(err.stack);
})
uSide
  • 36
  • 2
0

Use the --stack option to see stack traces. Such as grunt task --stack

numediaweb
  • 16,362
  • 12
  • 74
  • 110