Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 914
Inoperable Avatar asked Dec 05 '25 05:12

Inoperable


1 Answers

in nodejs i use this function to see error stack:

process.on('uncaughtException', function(err) {
    console.log(err.stack);
})
like image 112
uSide Avatar answered Dec 07 '25 21:12

uSide



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!