Inoperable
Inoperable

Reputation: 1509

node.js debugging with source line numbers

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.

Upvotes: 3

Views: 1731

Answers (2)

numediaweb
numediaweb

Reputation: 17010

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

Upvotes: 0

uSide
uSide

Reputation: 36

in nodejs i use this function to see error stack:

process.on('uncaughtException', function(err) {
    console.log(err.stack);
})

Upvotes: 2

Related Questions