How do I access the stack trace of a custom error in JavaScript?

Responsive Ad Header

Question

Grade: Education Subject: Support
How do I access the stack trace of a custom error in JavaScript?
Asked by:
64 Viewed 64 Answers
Responsive Ad After Question

Answer (64)

Best Answer
(283)
The stack trace is stored in the `stack` property of the error object. After catching a custom error, you can access it using `error.stack`. The format of the stack trace varies between browsers and Node.js, but it generally includes a list of function calls leading up to the error.