'How to get a raw error object on the try/catch instead of its stack [duplicate]

I'm trying to understand how I can get the raw object of the error in the try/catch block like so:

try {
  
} catch (error) {
  console.log(error);
}

The above is logging the stack instead of the raw object.

I'm asking this out of curiosity, because at first, I tried to print the message and not the stack and only by searching the web I could find this object has property of message.



Solution 1:[1]

There is error.stack which show the stack of error in string

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Simon G