Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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

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

Problem

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.

Problem courtesy of: Sean Bannister

Solution

Try error.stack

process.on('uncaughtException', function (error) {
   console.log(error.stack);
});
Solution courtesy of: mike

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

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

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×