Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js doesn't display entire error message on uncaughtException, is it possible?

Tags:

node.js

In node.js if you catch uncaughtExceptions, like so:

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

The error message displayed doesn't contain all the information that you receive if you don't catch the error and just let the process crash. When you let the process crash it includes what line caused the error. Is there any way to get the full error message including the line that caused the error so we can log this data using uncaughtException.

like image 749
Sean Bannister Avatar asked Feb 07 '12 17:02

Sean Bannister


People also ask

Why you shouldn't use node js?

Applications with heavy computing server-side. Since Node. js uses only one CPU core, heavy computations on the server will block all other requests. In this case, the event-driven non-blocking I/O model which is the strongest side of Node. js will become useless, and the application performance will suffer.

In which area node js is not recommended?

js receives a CPU bound task: Whenever a heavy request comes to the event loop, Node. js would set all the CPU available to process it first, and then answer other requests queued. That results in slow processing and overall delay in the event loop, which is why Node. js is not recommended for heavy computation.


1 Answers

Try error.stack

process.on('uncaughtException', function (error) {    console.log(error.stack); }); 
like image 139
mike Avatar answered Sep 19 '22 21:09

mike