Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 269
user1774309 Avatar asked Jun 02 '16 12:06

user1774309


1 Answers

Error object have a .message property containing the full message (no need for .toString(). There is also .stack but it's not a standardized property.

like image 190
Kulvar Avatar answered Oct 12 '22 12:10

Kulvar