Wednesday, May 25, 2016

Easily Track Javascript File and line number which has error

When all else fails, the issue may be caused by errors in your JavaScript application. A helpful way to determine this is to use the window.onerror function to track down your errors.

Easily Track Javascript File and line number which has error


window.onerror = function (err, fileName, lineNumber) {
   // alert or console.log a message
   alert(fileName, 'Line:', lineNumber, 'Error:', e.message);
};

Parameter info: 
// err: error message
// fileName: which file error occurs in
// lineNumber: what line error occurs on

No comments:

Post a Comment