1

Normally an Error class has properties such as name, code, message, stack etc. Some special errors such as OpenSSL Error uses Error class but also have opensslErrorStack etc. How can I print all properties in an Error?

I tried:

process.on('uncaughtException', function(err) {
  for (let i in err) {
    console.log(i + ': ' + err[i]);
  }
});
1

1 Answer 1

3

To just print the error object with all its properties in Node.js you can use util.inspect:

const { inspect } = require('util');

process.on('uncaughtException', err => {
  console.log(inspect(err, { showHidden: true }));
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.