Child pages
  • [system-log] Record JavaScript errors in "System Log" [5.3.0-B1]

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
$(window).on('error', function ($e) {
	var $original_event = $e.originalEvent;
	console.log($original_event);

	alert('col: ' + $original_event.colno + "\n" + 'line: ' + $original_event.lineno + "\n" + 'msg: ' + $original_event.message + "\n" + 'file: ' + $original_event.filename);
});

There is also not documented Error.prototype.stack property, which allows to retrieve stack track to the place, where error happened. The format of stack trace can vary greatly depending on used browser, but in general it can look like this:

No Format
Error: foobar
    at new bar (<anonymous>:241:11)
    at foo (<anonymous>:245:5)
    at callFunction (<anonymous>:229:33)
    at Object.InjectedScript._evaluateOn (<anonymous>:875:140)
    at Object.InjectedScript._evaluateAndWrap (<anonymous>:808:34)

Related Tasks