Search code examples
javascriptstack-traceonerror

JS how to convert to string the Error Object from the window.error?


I implemented:

 window.onerror = function (m, s, l, c, e) {
 }

Where the e is the Error Object. For example, it contains:

ReferenceError: rde is not defined
    at Object.bla.cs (domain.pt/bla.js:418:17)
    at n.aanv (domain.pt/bla.js:125:29)

If i make e.toString(), only the first line is returned. How to get the 3 lines? Thank you.


Solution

  • It seems that the Error Object has a property called stack. so, e.stack is the full text of the error.