Does anyone know how to print a stack trace in Node.js?
The printStackTrace() method of Java. lang. Throwable class used to print this Throwable along with other details like class name and line number where the exception occurred means its backtrace. This method prints a stack trace for this Throwable object on the standard error output stream.
The stack trace is used to trace the active stack frames at a particular instance during the execution of a program. The stack trace is useful while debugging code as it shows the exact point that has caused an error. Errors in Node.
You can use console. trace() to get a quick and easy stack trace to better understand code execution flow.
Any Error
object has a stack
member that traps the point at which it was constructed.
var stack = new Error().stack console.log( stack )
or more simply:
console.trace("Here I am!")
Now there's a dedicated function on console for that:
console.trace()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With